從在JavaScript this link,海關元件延伸按鈕被製成爲:extendTag在達特定製元素
var MegaButton = document.registerElement('mega-button', {
prototype: Object.create(HTMLButtonElement.prototype),
extends: 'button'
});
<button is="mega-button">
我試圖使所述使用鏢相同,通過這樣的代碼:
class MegaButton extends ButtonElement {
static final tag = 'mega-button';
factory MegaButton()=>new Element.tag('button', tag);
MegaButton.created() : super.created() {
var shadow = this.createShadowRoot();
shadow.text='save';
}
}
document.registerElement(MegaButton.tag, MegaButton);
在html文件
<button is="mega-button"></button>
<mega-button>click me</mega-button>
但得到了s錯誤:
Exception: Unsupported operation: Class must provide extendsTag if base native class is not HTMLElement
任何幫助請。感謝
哪條線導致異常? – 2014-10-11 15:48:00
document.registerElement(MegaButton.tag,MegaButton);這在一個單獨的函數中被調用,我註冊了所有的自定義元素。 – 2014-10-11 15:54:39