๐ธcustom element
browser โฉ web components โฉ implement โฉ custom elements
โญ custom element name ไธญ้ไธๅฎ่ฆๆ๏ผ"-
" โ
ไพๅฆ๏ผ
<vstack->
ๆ<v-stack>
โไฝ "
-
" ไธ่ฝๆพๅ้ข๏ผ<-vstack>
โ
define new custom elements with customElements.define().
custom elements render as inline elements by default.
Valid Custom Element Name
Register New Tag Name
We can create our tags by using the CustomElementRegistry object (window.customElements
).
custom element names must contain a hyphenโ ๐ customElements.define()
Custom elements cannot be self-closing because HTML only allows a few elements to be self-closing. Always write a closing tag (
<custom-element></custom-element>
) ๐ Google โฉ Custom Elements
Supporting Class
To create a custom element, we need to tell the browser several details about it: how to show it, what to do when the element is added or removed to page, etc.
Last updated
Was this helpful?