Files
tsbundle/test/ts_web/test-lit.ts

37 lines
765 B
TypeScript

import { LitElement, html, css } from 'lit';
import { customElement, property } from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
static styles = css`
:host {
display: block;
padding: 16px;
}
`;
@property({ type: String })
name = 'World';
@property({ type: Number })
count = 0;
render() {
return html`
<h1>Hello, ${this.name}!</h1>
<button @click=${this._onClick}>
Click Count: ${this.count}
</button>
`;
}
private _onClick() {
this.count++;
}
}
// Test instantiation
const element = new MyElement();
console.log('Element created:', element);
console.log('Element name:', element.name);
console.log('Element count:', element.count);