feat: update counter example
This commit is contained in:
parent
ec50f0f86e
commit
6eb93b5dd3
1 changed files with 8 additions and 6 deletions
|
@ -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>
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue