window.onerror = function(message, source, lineno, colno, error) { ... }
/ *
* message:错误信息(字符串)。可用于HTML onerror=""处理程序中的event。
* source:发生错误的脚本URL(字符串)
* lineno:发生错误的行号(数字)
* colno:发生错误的列号(数字)
* error:Error对象
*/
// 可以捕获资源加载异常
window.addEventListener("error",(error) => {
console.log("捕获到异常:", error);
},
true
);
console.log(notdefined111);
console.log("666");