【发布时间】:2016-09-11 18:02:44
【问题描述】:
可以在自定义元素上定义自定义函数吗?
类似:
var proto = Object.create(HTMLElement.prototype);
proto.customMethod = function () { ... };
document.registerElement('custom-el', {
prototype: proto
});
并在元素上调用方法:
var istance = document.createElement('custom-el');
instance.customMethod();
【问题讨论】:
标签: javascript html web-component custom-element