在 Polymer 中,如何使用 html 标签对数据进行数据绑定并使其正确显示
In Polymer how do I databind data with html tags and have it displayed correctly
如何在下方显示 div 中格式正确的 html?
谢谢:-)
<dom-module id='my-element'>
<template>
<div>{{html}}</div>
</template>
</dom-module>
<script>
Polymer({
is: 'my-element',
properties: {
html: {
type: String,
value: 'This is<br>a <strong>test</strong>'
}
}
});
</script>
<my-element></my-element>
像这样绑定 HTML 是不可取的,因为它目前是一个 XSS 向量,但是如果你决定这样做,你可以这样做:
<div inner-h-t-m-l="{{html}}"></div>
如何在下方显示 div 中格式正确的 html? 谢谢:-)
<dom-module id='my-element'>
<template>
<div>{{html}}</div>
</template>
</dom-module>
<script>
Polymer({
is: 'my-element',
properties: {
html: {
type: String,
value: 'This is<br>a <strong>test</strong>'
}
}
});
</script>
<my-element></my-element>
像这样绑定 HTML 是不可取的,因为它目前是一个 XSS 向量,但是如果你决定这样做,你可以这样做:
<div inner-h-t-m-l="{{html}}"></div>