wcb/sample.html
2023-11-18 23:27:23 +01:00

27 lines
704 B
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>WC Base Test</title>
<script type="module">
import WebComponent from "https://unpkg.com/web-component-base/index.js";
class HelloWorld extends WebComponent {
static properties = ["my-name"];
get template() {
return `<h1>Hello ${this.props.myName}!</h1>`;
}
}
customElements.define("hello-world", HelloWorld);
</script>
</head>
<body>
<hello-world my-name="Ayo"></hello-world>
<script>
const helloWorld = document.querySelector("hello-world");
setTimeout(() => {
helloWorld.props.myName = "Ayo zzzZzzz";
}, 2500);
</script>
</body>
</html>