Skip to content

Commit a52d7d8

Browse files
zh-cn: add new page for WebAssembly.LinkError (#27364)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent a22c9bb commit a52d7d8

File tree

1 file changed

+69
-0
lines changed
  • files/zh-cn/webassembly/reference/javascript_interface/linkerror

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: WebAssembly.LinkError
3+
slug: WebAssembly/Reference/JavaScript_interface/LinkError
4+
l10n:
5+
sourceCommit: 006c05b688814b45a01ad965bbe4ebfc15513e74
6+
---
7+
8+
**`WebAssembly.LinkError`** 对象表示模块实例化期间的错误(除启动函数中的[陷阱](https://webassembly.github.io/simd/core/intro/overview.html#trap))。
9+
10+
## 构造函数
11+
12+
- [`WebAssembly.LinkError()`](/zh-CN/docs/WebAssembly/Reference/JavaScript_interface/LinkError/LinkError)
13+
- : 创建一个新的 `WebAssembly.LinkError` 对象。
14+
15+
## 实例属性
16+
17+
- {{jsxref("Error.prototype.message", "WebAssembly.LinkError.prototype.message")}}
18+
- : 错误消息。继承自 {{jsxref("Error")}}。
19+
- {{jsxref("Error.prototype.name", "WebAssembly.LinkError.prototype.name")}}
20+
- : 错误名字。继承自 {{jsxref("Error")}}。
21+
- {{jsxref("Error.prototype.cause", "WebAssembly.LinkError.prototype.cause")}}
22+
- : 错误原因。继承自 {{jsxref("Error")}}。
23+
- {{jsxref("Error.prototype.fileName", "WebAssembly.LinkError.prototype.fileName")}} {{non-standard_inline}}
24+
- : 引发此错误的文件所在的路径。继承自 {{jsxref("Error")}}。
25+
- {{jsxref("Error.prototype.lineNumber", "WebAssembly.LinkError.prototype.lineNumber")}} {{non-standard_inline}}
26+
- : 在引发此错误的文件中的行号。继承自 {{jsxref("Error")}}。
27+
- {{jsxref("Error.prototype.columnNumber", "WebAssembly.LinkError.prototype.columnNumber")}} {{non-standard_inline}}
28+
- : 在引发此错误的行中的列号。继承自 {{jsxref("Error")}}。
29+
- {{jsxref("Error.prototype.stack", "WebAssembly.LinkError.prototype.stack")}} {{non-standard_inline}}
30+
- : 堆栈跟踪。继承自 {{jsxref("Error")}}。
31+
32+
## 实例方法
33+
34+
- {{jsxref("Error.prototype.toString", "WebAssembly.LinkError.prototype.toString()")}}
35+
- : 返回一个表示指定的 `Error` 对象的字符串。继承自 {{jsxref("Error")}}。
36+
37+
## 示例
38+
39+
### 创建一个新的 LinkError 实例
40+
41+
下面的代码片段创建一个新的 `LinkError` 实例,并将其详情输出到控制台:
42+
43+
```js
44+
try {
45+
throw new WebAssembly.LinkError("你好", "某个文件", 10);
46+
} catch (e) {
47+
console.log(e instanceof LinkError); // true
48+
console.log(e.message); // "你好"
49+
console.log(e.name); // "LinkError"
50+
console.log(e.fileName); // "某个文件"
51+
console.log(e.lineNumber); // 10
52+
console.log(e.columnNumber); // 0
53+
console.log(e.stack); // 返回运行代码的位置
54+
}
55+
```
56+
57+
## 规范
58+
59+
{{Specifications}}
60+
61+
## 浏览器兼容性
62+
63+
{{Compat}}
64+
65+
## 参见
66+
67+
- [WebAssembly](/zh-CN/docs/WebAssembly) 概览
68+
- [WebAssembly 概念](/zh-CN/docs/WebAssembly/Guides/Concepts)
69+
- [使用 WebAssembly JavaScript API](/zh-CN/docs/WebAssembly/Guides/Using_the_JavaScript_API)

0 commit comments

Comments
 (0)