window.onerror = function (message, url, line, col, error) {
alert(`${message}\n At ${line}:${col} of ${url}`);
};
function readData() {
badFunc(); // Whoops, something went wrong!
}
readData();
为什么当我在外部js文件中运行此代码时出现脚本错误 但是,当html文件中的脚本标记中包含的代码运行并给我错误:未捕获的参考错误:badFunc未定义