aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/element/createshadowroot/index.html
blob: 51edc306b5f45ac96549b2c241c302e4820f77e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---
title: Element.createShadowRoot()
slug: Web/API/Element/createShadowRoot
translation_of: Web/API/Element/createShadowRoot
---
<p>使用<code>Element.createShadowRoot</code> 创建的实例 <a href="/en-US/docs/Web/Web_Components/Shadow_DOM">阴影DOM</a>。创建shadow DOM时,它始终附加到现有元素。创建shadow DOM之后,它所附加的元素称为{{glossary("shadow root")}}</p>

<div class="note">
<p>不推荐使用此方法,而使用{{DOMxRef("Element.attachShadow()","attachShadow()")}}</p>
</div>

<h2 id="Syntax" name="Syntax">句法</h2>

<pre class="syntaxbox">var <em>shadowroot = </em><em>element</em>.createShadowRoot();
</pre>

<h3 id="参数">参数</h3>

<p>没有参数。</p>

<h3 id="结果值">结果值</h3>

<p>返回{{DOMxRef("ShadowRoot")}}</p>

<h2 id="产品规格">产品规格</h2>

<p>任何规格都不再定义此功能。</p>

<h2 id="浏览器兼容性">浏览器兼容性</h2>