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