当使用影子DOM创建自定义元素并设置元素的innerHTML时,它不会被显示。为什么?是否有方法可以防止这种情况发生?
//JS代码
//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>