[HTML5] Render Hello World Text with Custom Elements
html5 with Text Hello World Elements Custom render
2023-09-14 09:00:49 时间
Custom elements are fun technology. In this video, you will learn how to set one up and running in less than 2 minutes.
You'll learn how to create a Custom Web Element (that extends HTMLElement
) that renders text to the browser and respond to a click event listener.
class MyCustomElement extends HTMLElement { constructor() { super(); this.addEventListener("mouseover", () => console.log("Hello World")); } //lifecycle connectedCallback() { this.innerHTML = `<h1>Hello Custom ELement</h1>`; } } window.customElements.define("zwt-element", MyCustomElement);
<!DOCTYPE html> <html> <head> <title>Custom Element</title> <meta charset="UTF-8" /> </head> <body> <div id="app"></div> <zwt-element [msg]="greeting" /> <script src="src/index.js"> </script> </body> </html>
More about custome element
相关文章
- 基于 HTML5 Canvas 的 3D 机房创建
- 基于 HTML5 Canvas 绘制的电信网络拓扑图
- HTML5 LocalStorage 本地存储(转)
- html5学习(三)
- [HTML] Change an HTML5 input's placeholder color with CSS
- html5 audio音频播放全解析
- html5学习(三)
- 【HTML5】Application Cache应用程序缓存
- [HTML5] Layout Reflow & thrashing
- [HTML5] Show Images of Differing Resolutions Depending on the Viewport Width with srcset
- HTML5_路径
- html5本地存储