get()
方法在
CustomElementRegistry
interface returns the constructor for a previously-defined custom element.
constructor = customElements.get(name);
The name of the custom element whose constructor you want to return a reference to.
The constructor for the named custom element, or
undefined
if there is no custom element definition with that name.
customElements.define('my-paragraph',
class extends HTMLElement {
constructor() {
super();
let template = document.getElementById('my-paragraph');
let templateContent = template.content;
const shadowRoot = this.attachShadow({mode: 'open'})
.appendChild(templateContent.cloneNode(true));
}
})
// Return a reference to the my-paragraph constructor
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'customElements.get()' in that specification. |
实时标准 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
get
|
Chrome
66
注意事项
|
Edge
79
注意事项
|
Firefox
63
|
IE 不支持 No |
Opera
53
注意事项
|
Safari
10.1
注意事项
|
WebView Android
66
注意事项
|
Chrome Android
66
注意事项
|
Firefox Android
63
|
Opera Android
47
注意事项
|
Safari iOS
10.3
注意事项
|
Samsung Internet Android
9.0
注意事项
|
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
用户必须明确启用此特征。