mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-15 07:06:53 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
</div></div>
|
||||
<p>Array<strong>.unobserve()方法用来移除</strong><a href="Reference/Global_Objects/Array/observe" title='Array.observe() 方法用于异步监视数组发生的变化,类似于针对对象的 Object.observe() 。当数组的值发生变化时,它按发生顺序提供了一个变化流。与 Object.observe() 类似,它由如下可接受的变化类型列表["add"、"update"、"delete"、"splice"]触发。'><code>Array.observe()</code></a>设置的所有观察者。</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code>Array.unobserve(<var>arr</var>, <var>callback</var>)</code></pre>
|
||||
<pre><code class="language-javascript"><code>Array.unobserve(<var>arr</var>, <var>callback</var>)</code></code></pre>
|
||||
<h3 id="参数">参数</h3>
|
||||
<dl>
|
||||
<dt><code>arr</code></dt>
|
||||
@@ -19,7 +19,7 @@
|
||||
<p>回调函数应该是一个函数的引用并且不能是匿名函数, 因为这个函数需要用来移除前面的观察者, 如果用匿名函数是没有用的,将不能移除任何观察者。</p>
|
||||
<h2 id="例子">例子</h2>
|
||||
<h3 id="停止观察一个数组">停止观察一个数组</h3>
|
||||
<pre class="brush: js">var arr = [1, 2, 3];
|
||||
<pre><code class="language-javascript">var arr = [1, 2, 3];
|
||||
|
||||
var observer = function(changes) {
|
||||
console.log(changes);
|
||||
@@ -33,9 +33,9 @@ arr.push(4);
|
||||
Array.unobserve(arr, observer);
|
||||
|
||||
arr.pop();
|
||||
// The callback wasn't called</pre>
|
||||
// The callback wasn't called</code></pre>
|
||||
<h3 id="使用匿名函数">使用匿名函数</h3>
|
||||
<pre class="brush: js">var persons = ['Khalid', 'Ahmed', 'Mohammed'];
|
||||
<pre><code class="language-javascript">var persons = ['Khalid', 'Ahmed', 'Mohammed'];
|
||||
|
||||
Array.observe(persons, function (changes) {
|
||||
console.log(changes);
|
||||
@@ -51,7 +51,7 @@ Array.unobserve(persons, function (changes) {
|
||||
persons.push('Abdullah');
|
||||
// [{type: "splice", object: <arr>, index: 2, removed: [], addedCount: 1 }]
|
||||
// The callback will always be called
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="浏览器兼容性">浏览器兼容性</h2>
|
||||
<div>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user