diff options
Diffstat (limited to 'files/zh-cn/web/api/mutationobserver/disconnect/index.html')
-rw-r--r-- | files/zh-cn/web/api/mutationobserver/disconnect/index.html | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/mutationobserver/disconnect/index.html b/files/zh-cn/web/api/mutationobserver/disconnect/index.html new file mode 100644 index 0000000000..7de675ca81 --- /dev/null +++ b/files/zh-cn/web/api/mutationobserver/disconnect/index.html @@ -0,0 +1,74 @@ +--- +title: MutationObserver.disconnect() +slug: Web/API/MutationObserver/disconnect +translation_of: Web/API/MutationObserver/disconnect +--- +<div>{{APIRef("DOM WHATWG")}}</div> + +<p><span class="seoSummary">{{domxref("MutationObserver")}} 的 <code><strong>disconnect()</strong></code> 方法告诉观察者停止观察变动。</span> 可以通过调用其{{domxref("MutationObserver.observe", "observe()")}}方法来重用观察者。</p> + +<ul> +</ul> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><em>mutationObserver</em>.disconnect() +</pre> + +<h3 id="参数">参数</h3> + +<p>无。</p> + +<h3 id="返回值">返回值</h3> + +<p><code>undefined</code>.</p> + +<div class="note"> +<p><strong>注意:</strong> 所有已经检测到但是尚未向观察者报告的变动都会被丢弃。</p> +</div> + +<h2 id="使用说明">使用说明</h2> + +<p>如果被观察的元素被从DOM中移除,然后被浏览器的垃圾回收机制释放,此<code>MutationObserver</code>将同样被删除。</p> + +<h2 id="示例">示例</h2> + +<p>下面的示例创建了一个观察者,接着与之断开连接,让它可以重复使用。</p> + +<pre class="brush: js">var targetNode = document.querySelector("#someElement"); +var observerOptions = { + childList: true, + attributes: true +} + +var observer = new MutationObserver(callback); +observer.observe(targetNode, observerOptions); + +/* some time later... */ + +observer.disconnect();</pre> + +<h2 id="Specifications" name="Specifications">规范</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">批注</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('DOM WHATWG', '#dom-mutationobserver-disconnect', 'MutationObserver.disconnect()')}}</td> + <td>{{ Spec2('DOM WHATWG') }}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("api.MutationObserver.disconnect")}}</p> |