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