nor*_*rth 6 polymer polymer-1.0
我的Polymer组件的模板的一部分应该从JSON响应中呈现未转义的HTML(是的,在这种情况下这样做是安全的).到目前为止,我使用了juicy-html(https://github.com/Juicy/juicy-html),但它不再适用于Polymer 1.x.
我的模板的相应部分看起来非常像这样:
<template if="{{item.part1}}">
<div>
<template is="juicy-html" content="{{item.part1.part2 | callFunction}}"></template>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我读了一些关于使用早期版本的Polymer注入HTML的解决方案,但是我想知道是否有一种"规范方式"来实现这个1.x?
Zik*_*kes 11
绑定节点innerHTML属性的一种有点破解方法:
<div inner-h-t-m-l="{{myProp}}"></div>
Run Code Online (Sandbox Code Playgroud)
Polymer通过连字符推断大写,将后续字符转换为大写,当使用equals(=)而不是equals-dollar(=$)时,Polymer绑定到节点的属性而不是属性.