window.onerror捕捉页面异常事件,使用这个方法可以上报埋点,便于问题的定位。上报内容:页面信息、报错信息
window.onerror = function (msg) {
console.log(msg)
}
console.log(aa)
// Uncaught ReferenceError: aa is not defined
// onError.html:10 Uncaught ReferenceError: aa is not defined
// at onError.html:10