feat: update counter example

This commit is contained in:
Ayo 2023-12-09 22:52:17 +01:00
parent ec50f0f86e
commit 6eb93b5dd3

View file

@ -1,14 +1,16 @@
// @ts-check
import { WebComponent } from "../../src/index.js"
import { WebComponent, html } from "../../src/index.js"
export class Counter extends WebComponent {
static properties = ["count"];
onInit() {
this.props.count = 0;
this.onclick = () => ++this.props.count;
static props = {
count: 0
}
get template() {
return `<button id="btn">${this.props.count}</button>`;
return html`
<button onClick=${() => ++this.props.count} id="btn">
${this.props.count}
</button>
`;
}
}