is
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
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>
规范
Specification |
---|
HTML # attr-is |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
is |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
参见
- All global attributes.