ES6語法,自定義組件的命名

標籤命名必定要加「-」,浪費了半個小時。。。java

class MxmBox extends HTMLElement {
      constructor() {
        super();
        console.log(this);
        let but=document.createElement('button');
        but.innerText='第一個按鈕';
        this._shadowDom = this.attachShadow({ mode: "open" });
        this._shadowDom.appendChild(but);
      }
    }

    customElements.define("mx-m", MxmBox);
相關文章
相關標籤/搜索