is
允许您指定标准HTML元素应该像已注册的自定义内置元素一样。
只有在当前文档中已成功定义(defined)指定的自定义元素名称并且扩展了要应用的元素类型时,才能使用此属性。
示例
以下代码来自我们的word-count-web-component示例(see it live also)。
// 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' } );
<p is="word-count"></p>
浏览器支持
![]() | ![]() | ![]() | ![]() | ![]() |
IE、safari览器不支持is属性 |