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.

浏览器兼容性

BCD tables only load in the browser

参见