mcfly/public/components/hello-world.js
2023-10-07 20:06:23 +02:00

20 lines
468 B
JavaScript

import WebComponent from "https://unpkg.com/web-component-base/index.js";
export default class HelloWorld extends WebComponent {
name = "";
static properties = ["name"];
onInit() {
console.log(`Greeting for ${this.name} initialized`);
let count = 0;
this.onclick = () => {
console.log("Clicked!");
this.name = `I was clicked ${++count} times`;
this.render();
};
}
get template() {
return `Hello ${this.name}!`;
}
}