【发布时间】:2020-01-19 20:02:38
【问题描述】:
因为我想保持自定义元素自包含,所以我想避免在window 对象上放置对成员变量的引用。
customElements.define( 'component-one', class extends HTMLElement {
connectedCallback() {
this.memberVariable="This is a member variable";
this.innerHTML = "<button onclick='//How do I reference the above this.memberVariable here?'>This is a button</button>";
}
}):
【问题讨论】:
标签: javascript html web-component custom-element native-web-component