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
|
||||
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>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue