关于 js 私有属性的新语法
class Counter extends HTMLElement {
#x = 0;
clicked() {
this.#x++;
window.requestAnimationFrame(this.render.bind(this));
}
constructor() {
super();
this.onclick = this.clicked.bind(this);
}
connectedCallback() { this.render(); }
render() {
this.textContent = this.#x.toString();
}
}
window.customElements.define('num-counter', Counter);
下面的评论😄
__________\
/ \\\
/ REST \\\
/ IN \\\
/ PEACE \\\
/ \\\
| es |\
| |\
| killed by a |\
| private-fields |\
| 2018 |\
*| * * * | *\
________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______
传送门