Typescript Class-Component
import { html, JDOMComponent } from 'jdomjs'
import { CustomElement, State } from "jdomjs/decorator.ts";
@CustomElement('example-component')
class ExampleComponent extends JDOMComponent {
@State()
private name: Hook<String> = 'John'
@Computed(s => [s.name])
private greetings() {
return comp`Hello ${this.name}`
}
render() {
return html`
<input :bind=${this.name}>
<h1>${this.greetings}</h1>
`
}
}
Javascript Class-Component
import { html, JDOMComponent, $r } from 'jdomjs'
class ExampleComponent extends JDOMComponent {
private name = new Hook('John')
private greetings() {
return comp`Hello ${this.name}`
}
render() {
return html`
<input :bind=${this.name}>
<h1>${this.greetings()}</h1>
`
}
}
$r('example-component', ExampleComponent)