Error.prototype.lineNumber
非标准: 该特性是非标准的,请尽量不要在生产环境中使用它!
lineNumber
属性的值为抛出错误的代码在其源文件中所在的行号。
示例
使用 lineNumber
js
var e = new Error("Could not parse input");
throw e;
console.log(e.lineNumber); // 2
监听 error
事件的示例
js
window.addEventListener("error", function (e) {
console.log(e.lineNumber); // 5
});
var e = new Error("Could not parse input");
throw e;
这不是一个标准化的属性,缺乏广泛的支持。参见下面的浏览器兼容性表格。
规范
非标准化属性。不属于任何规范。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lineNumber |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Non-standard. Check cross-browser support before using.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.