mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-17 00:04:34 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
<div></div>
|
||||
<p> <strong><code>handler.has()</code></strong> 方法可以看作是针对 <a href="Reference/Operators/in" title="如果指定的属性在指定的对象或其原型链中,则in 运算符返回true。"><code>in</code></a> 操作的钩子.</p>
|
||||
<h2 id="Syntax">Syntax</h2>
|
||||
<pre class="brush: js">var p = new Proxy(target, {
|
||||
<pre><code class="language-javascript">var p = new Proxy(target, {
|
||||
has: function(target, prop) {
|
||||
}
|
||||
});
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h3 id="Parameters">Parameters</h3>
|
||||
<p><code>下面是传递给 has</code> 方法的参数. <code>this</code> is bound to the handler.</p>
|
||||
<dl>
|
||||
@@ -35,7 +35,7 @@
|
||||
</ul>
|
||||
<h2 id="Examples">Examples</h2>
|
||||
<p>下面的代码 hook 了 <a href="Reference/Operators/in" title="如果指定的属性在指定的对象或其原型链中,则in 运算符返回true。"><code>in</code></a> 操作.</p>
|
||||
<pre class="brush: js">var p = new Proxy({}, {
|
||||
<pre><code class="language-javascript">var p = new Proxy({}, {
|
||||
has: function(target, prop) {
|
||||
console.log('called: ' + prop);
|
||||
return true;
|
||||
@@ -44,9 +44,9 @@
|
||||
|
||||
console.log('a' in p); // "called: a"
|
||||
// true
|
||||
</pre>
|
||||
</code></pre>
|
||||
<p>下面的代码违反了规则.</p>
|
||||
<pre class="brush: js">var obj = { a: 10 };
|
||||
<pre><code class="language-javascript">var obj = { a: 10 };
|
||||
Object.preventExtensions(obj);
|
||||
var p = new Proxy(obj, {
|
||||
has: function(target, prop) {
|
||||
@@ -55,7 +55,7 @@ var p = new Proxy(obj, {
|
||||
});
|
||||
|
||||
'a' in p; // TypeError is thrown
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="Specifications">Specifications</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user