非标准
该特性是非标准的,请尽量不要在生产环境中使用它!
lineNumber
属性的值为抛出错误的代码在其源文件中所在的行号。
示例
使用 lineNumber
var e = new Error('Could not parse input'); throw e; console.log(e.lineNumber) // 2
监听 error
事件的示例
window.addEventListener('error', function(e) { console.log(e.lineNumber); // 5 }); var e = new Error('Could not parse input'); throw e;
这不是一个标准化的属性,缺乏广泛的支持。参见下面的浏览器兼容性表格。
规范
非标准化属性。不属于任何规范。
浏览器兼容性
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.
Update compatibility data on GitHub
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lineNumber
|
Chrome No support No | Edge No support No | Firefox Full support 1 | IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Firefox Android Full support 4 | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No |
Legend
- Full support
- Full support
- No support
- No support
- Non-standard. Expect poor cross-browser support.
- Non-standard. Expect poor cross-browser support.