2016-09-11 5 views

答えて

2

はい、:

var proto = Object.create(HTMLElement.prototype); 
proto.customMethod = function() { ... }; 

document.registerElement('custom-el', { 
    prototype: proto 
}); 

と要素にメソッドを呼び出します。

var proto = Object.create(HTMLElement.prototype); 
 
proto.customMethod = function() { 
 
    console.log('customMethod called') 
 
}; 
 

 
document.registerElement('custom-el', { 
 
    prototype: proto 
 
}); 
 
var instance = document.createElement('custom-el'); 
 
instance.customMethod();

:あなたは以下のコードで見ることができるよう

あなたの例では、動作します

関連する問題