How to display html inside template?

前端 未结 2 1351
广开言路
广开言路 2021-01-24 13:02

I have polymer-element:

example

By default templates is not allowed to insert html.

This sample is not working, because it\'s not allowed to insert

相关标签:
2条回答
  • 2021-01-24 13:31

    One way to do this is through a *Changed watcher and setting the .innerHTML the node:

    <div id="div"></div>
    
    labelChanged: function() {
      this.$.div.innerHTML = this.label;
    }
    

    Then, for the <template repeat> case, wrap things up in a custom element that follows the similar pattern: https://stackoverflow.com/a/22208332.

    0 讨论(0)
  • 2021-01-24 13:36
    <element inner-h-t-m-l="{{prop}}"></element>
    

    works for Polymer 2. Source: https://github.com/Polymer/TemplateBinding/issues/57

    0 讨论(0)
提交回复
热议问题