【发布时间】:2018-01-22 16:42:35
【问题描述】:
我在使用模板的地方用这段代码创建了一个 Web 组件:
let tmpl = document.createElement('template');
tmpl.innerHTML =`<style>
div {
color: green;
display: inline;
margin: 3px;
}
p {
border: 1px solid black;
}
</style>
<p>
Hello my name is:
<div>Web</div>
<div>Component</div>
</p>`;
this.shadowRoot.appendChild(tmpl.content.cloneNode(true));
但在控制台的影子根目录中,我看到的内容不一样:
【问题讨论】:
标签: web-component shadow-dom html5-template native-web-component