Error.prototype.fileName

非标准: 该特性是非标准的,请尽量不要在生产环境中使用它!

fileName 属性包含引发此错误的文件的路径。

描述

此非标准属性包含引发此错误的文件的路径。如果从调试器上下文调用,例如 Firefox Developer Tools,将会返回“debugger eval code”.

示例

使用 fileName

js
var e = new Error("Could not parse input");
throw e;
// e.fileName could look like "file:///C:/example.html"

规范

No specification found

No specification data found for javascript.builtins.Error.fileName.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
fileName
Non-standard

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.

参见