aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/proxy/handler/apply
diff options
context:
space:
mode:
authorFlorian Merz <me@fiji-flo.de>2021-02-11 12:56:40 +0100
committerFlorian Merz <me@fiji-flo.de>2021-02-11 12:56:40 +0100
commit310fd066e91f454b990372ffa30e803cc8120975 (patch)
treed5d900deb656a5da18e0b60d00f0db73f3a2e88e /files/zh-cn/web/javascript/reference/global_objects/proxy/handler/apply
parent8260a606c143e6b55a467edf017a56bdcd6cba7e (diff)
downloadtranslated-content-310fd066e91f454b990372ffa30e803cc8120975.tar.gz
translated-content-310fd066e91f454b990372ffa30e803cc8120975.tar.bz2
translated-content-310fd066e91f454b990372ffa30e803cc8120975.zip
unslug zh-cn: move
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/proxy/handler/apply')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/proxy/handler/apply/index.html117
1 files changed, 0 insertions, 117 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/proxy/handler/apply/index.html b/files/zh-cn/web/javascript/reference/global_objects/proxy/handler/apply/index.html
deleted file mode 100644
index 62b8b67f5f..0000000000
--- a/files/zh-cn/web/javascript/reference/global_objects/proxy/handler/apply/index.html
+++ /dev/null
@@ -1,117 +0,0 @@
----
-title: handler.apply()
-slug: Web/JavaScript/Reference/Global_Objects/Proxy/handler/apply
-tags:
- - ECMAScript6
- - JavaScript
- - Method
- - Proxy
-translation_of: Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/apply
----
-<div>{{JSRef}}</div>
-
-<p><strong><code>handler.apply()</code></strong> 方法用于拦截函数的调用。</p>
-
-<div>{{EmbedInteractiveExample("pages/js/proxyhandler-apply.html", "taller")}}</div>
-
-<p class="hidden">此交互式示例的源代码存储在GitHub存储库中。 如果您想为交互式示例项目做出贡献,请克隆 <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> 并向我们发起拉取请求</p>
-
-<h2 id="语法">语法</h2>
-
-<pre class="brush: js">var p = new Proxy(target, {
- apply: function(target, thisArg, argumentsList) {
- }
-});
-</pre>
-
-<h3 id="参数">参数</h3>
-
-<p>以下是传递给apply方法的参数,<code>this上下文绑定在</code>handler对象上.</p>
-
-<dl>
- <dt><code>target</code></dt>
- <dd>目标对象(函数)。</dd>
- <dt><code>thisArg</code></dt>
- <dd>被调用时的上下文对象。</dd>
- <dt><code>argumentsList</code></dt>
- <dd>被调用时的参数数组。</dd>
-</dl>
-
-<h3 id="返回值">返回值</h3>
-
-<p><code>apply方法可以返回任何值。</code></p>
-
-<h2 id="描述">描述</h2>
-
-<p><strong><code>handler.apply</code></strong> 方法用于拦截函数的调用。</p>
-
-<h3 id="拦截">拦截</h3>
-
-<p>该方法会拦截目标对象的以下操作:</p>
-
-<ul>
- <li><code>proxy(...args)</code></li>
- <li>{{jsxref("Function.prototype.apply()")}} 和 {{jsxref("Function.prototype.call()")}}</li>
- <li>{{jsxref("Reflect.apply()")}}</li>
-</ul>
-
-<h3 id="约束">约束</h3>
-
-<p>如果违反了以下约束,代理将抛出一个TypeError:</p>
-
-<p><code>target</code>必须是可被调用的。也就是说,它必须是一个函数对象。</p>
-
-<h2 id="示例">示例</h2>
-
-<p>以下代码演示如何捕获函数的调用。</p>
-
-<pre class="brush: js">var p = new Proxy(function() {}, {
- apply: function(target, thisArg, argumentsList) {
- console.log('called: ' + argumentsList.join(', '));
- return argumentsList[0] + argumentsList[1] + argumentsList[2];
- }
-});
-
-console.log(p(1, 2, 3)); // "called: 1, 2, 3"
- // 6
-</pre>
-
-<h2 id="规范">规范</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Specification</th>
- <th scope="col">Status</th>
- <th scope="col">Comment</th>
- </tr>
- <tr>
- <td>{{SpecName('ES2015', '#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist', '[[Call]]')}}</td>
- <td>{{Spec2('ES2015')}}</td>
- <td>Initial definition.</td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist', '[[Call]]')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td> </td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="浏览器兼容性">浏览器兼容性</h2>
-
-<div>
-<div class="hidden">此页面上的兼容性表格由结构化数据生成。 如果您想为数据做出贡献,请检出 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 并向我们发出拉取请求。</div>
-
-<p>{{Compat("javascript.builtins.Proxy.handler.apply")}}</p>
-</div>
-
-<h2 id="另见">另见</h2>
-
-<ul>
- <li>{{jsxref("Proxy")}}</li>
- <li>{{jsxref("Proxy.handler", "handler")}}</li>
- <li>{{jsxref("Function.prototype.apply")}}</li>
- <li>{{jsxref("Function.prototype.call")}}</li>
- <li>{{jsxref("Reflect.apply()")}}</li>
-</ul>