click-counter.ts 579 B

1234567891011121314151617181920212223242526272829303132
  1. import {LitElement, html, css} from 'lit-element';
  2. import {customElement, property} from 'lit/decorators.js';
  3. @customElement('click-counter')
  4. export class ClickCounter extends LitElement {
  5. static styles = css`
  6. :host {
  7. display: block;
  8. }
  9. `;
  10. @property({type: Number})
  11. count = 0;
  12. render() {
  13. return html`
  14. <button @click=${this._onClick}>
  15. Click count: ${this.count}
  16. </button>
  17. `;
  18. }
  19. private _onClick() {
  20. this.count++;
  21. }
  22. }
  23. declare global {
  24. interface HTMLElementTagNameMap {
  25. 'click-counter': ClickCounter;
  26. }
  27. }