is
æéå¯ç¨
æ¤ç¹æ§ä¸å±äºåºçº¿ï¼å 为å®å°æªå¨ä¸»æµæµè§å¨ä¸å¾å°æ¯æã
is å
¨å±å±æ§å
è®¸ä½ æå®æ å HTML å
ç´ åå®ä¹çå
ç½®å
ç´ ä¸æ ·å·¥ä½ï¼è¯·åé
使ç¨èªå®ä¹å
ç´ ä»¥è·åæ´å¤è¯¦ç»ä¿¡æ¯ï¼ã
åªæå¨å½åææ¡£ä¸å·²æåå®ä¹ ( defined ) æå®çèªå®ä¹å ç´ åç§°å¹¶ä¸æ©å±äºè¦åºç¨çå ç´ ç±»åæ¶ï¼æè½ä½¿ç¨æ¤å±æ§ã
示ä¾
以ä¸ä»£ç æ¥èªæä»¬ç word-count-web-component 示ä¾ï¼see it live alsoï¼ã
js
// Create a class for the element
class WordCount extends HTMLParagraphElement {
constructor() {
// Always call super first in constructor
super();
// Constructor contents ommitted for brevity
...
}
}
// Define the new element
customElements.define('word-count', WordCount, { extends: 'p' });
html
<p is="word-count"></p>
è§è
| è§è |
|---|
| HTML > # attr-is > |
æµè§å¨å ¼å®¹æ§
åè§
- All global attributes.