【发布时间】:2018-12-19 11:07:53
【问题描述】:
当使用 shadow dom 创建自定义元素并设置元素的 innerHTML 时,它不会显示。为什么?有没有办法防止这种情况发生?
//JS代码
export default class VideoPlayer extends DomElement {
constructor() {
super();
const mountPoint = document.createElement('div');
this.attachShadow({ mode: 'open' }).appendChild(mountPoint);
}
}
window.customElements.define('video-player', VideoPlayer);
//HTML 代码
<video-player>Why is this text hidden?</video-player>
【问题讨论】:
标签: javascript innerhtml web-component shadow-dom custom-element