add hello sayer component excercise
Neue Datei |
| | |
| | | <!DOCTYPE html>
|
| | | <html lang="en">
|
| | | <head>
|
| | | <meta charset="UTF-8">
|
| | | <title>Web Components</title>
|
| | | <script defer src="hello-sayer.js"></script>
|
| | | </head>
|
| | | <body>
|
| | | <hello-sayer></hello-sayer>
|
| | | </body>
|
| | | </html>
|
Neue Datei |
| | |
| | | class HelloSayerComponent extends HTMLElement {
|
| | | connectedCallback() {
|
| | | const shadowRoot = this.attachShadow({mode: "open"});
|
| | |
|
| | | shadowRoot.innerHTML = `
|
| | | <style>
|
| | | div {
|
| | | background-color: coral;
|
| | | color: white;
|
| | | }
|
| | | </style>
|
| | | <div>Hello!</div>
|
| | | `;
|
| | | }
|
| | | }
|
| | |
|
| | | window.customElements.define("hello-sayer", HelloSayerComponent);
|