aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/webassembly/module
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/webassembly/module
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/webassembly/module')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html87
1 files changed, 87 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html
new file mode 100644
index 0000000000..c328e5f3ba
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html
@@ -0,0 +1,87 @@
+---
+title: WebAssembly.Module
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/Module
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Module
+---
+<div>{{JSRef}}</div>
+
+<div><strong><code>WebAssembly.Module</code></strong> 对象包含已经由浏览器编译的无状态 WebAssembly 代码,可以高效地<a href="https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage">与 Workers 共享</a>、<a href="https://developer.mozilla.org/en-US/docs/WebAssembly/Caching_modules">缓存在 IndexedDB 中</a>,和多次实例化。</div>
+
+<div> </div>
+
+<div><code>WebAssembly.Module()</code> 构造函数可以用来同步编译给定的 WebAssembly 二进制代码。不过,获取 <code>Module</code> 对象的主要方法是通过异步编译函数,如 {{jsxref("WebAssembly.compile()")}},或者是<a href="/en-US/docs/WebAssembly/Caching_modules">通过 IndexedDB 读取 Module 对象</a>.</div>
+
+<div> </div>
+
+<h2 id="构造函数语法">构造函数语法</h2>
+
+<div class="warning">
+<p><strong>重要提示:</strong>由于大型模块的编译可能很消耗资源,开发人员只有在绝对需要同步编译时,才使用 <code>Module()</code> 构造函数;其他情况下,应该使用异步 {{jsxref("WebAssembly.compile()")}} 方法。</p>
+</div>
+
+<pre class="syntaxbox">var myModule = new WebAssembly.Module(bufferSource);</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><em>bufferSource</em></dt>
+ <dd>一个 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays">类型化数组</a> 或 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a>,包含要编译的 .wasm 模块的二进制代码。</dd>
+</dl>
+
+<h2 id="Module_构造函数的方法属性"><code>Module</code> 构造函数的方法属性</h2>
+
+<dl>
+ <dt>{{jsxref("Global_Objects/WebAssembly/Module/customSections", "WebAssembly.Module.customSections()")}}</dt>
+ <dd>给定 <code>Module</code> 对象和字符串,通过该字符串,返回 Module 对象中所有自定义部分的内容的副本。</dd>
+ <dt>{{jsxref("Global_Objects/WebAssembly/Module/exports", "WebAssembly.Module.exports()")}}</dt>
+ <dd>给定 <code>Module</code> 对象,返回一个数组,内容是所有已声明的接口的描述。</dd>
+ <dt>{{jsxref("Global_Objects/WebAssembly/Module/imports", "WebAssembly.Module.imports()")}}</dt>
+ <dd>给定 <code>Module</code> 对象,返回一个数组,内容是所有已声明的引用的描述。</dd>
+</dl>
+
+<h2 id="Module_实例"><code>Module</code> 实例</h2>
+
+<p>所有 <code>Module</code> 实例继承自 <code>Module()</code> 构造函数的<a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/prototype">原型对象</a> —— 修改它会影响所有 <code>Module</code> 实例。</p>
+
+<h3 id="实例属性">实例属性</h3>
+
+<p>{{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/prototype', 'Properties')}}</p>
+
+<h3 id="实例方法">实例方法</h3>
+
+<p>Module 实例没有自己的默认方法。</p>
+
+<h2 id="规范">规范</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('WebAssembly JS', '#webassemblymodule-objects', 'WebAssembly.Module()')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>定义初稿</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</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.WebAssembly.Module")}}</p>
+</div>
+
+<h2 id="另请查阅">另请查阅</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> 概览页面</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly 概念</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">使用 WebAssembly JavaScript API</a></li>
+</ul>