使用 jsErrLog 分析 js 报错

时间:2023-03-08 16:33:37
1. github 地址:
https://github.com/Offbeatmammal/jsErrLog/tree/master/src 2. 在所有页面引入 jsErrLog,配置出错时打日志的 url
window.jsErrLog.url = "/jserr.html"; 3. 配置 ajax 出错时打日志
;(function(){
$(document).ajaxError(function(event, xhr, options){
var msg = [];
if(typeof xhr == "object"){
msg.push('status:' + xhr.status);
msg.push('statusText:' + xhr.statusText);
}
if(typeof options == "object"){
msg.push('url:' + options.url);
msg.push('data:' + options.data);
}
window.onerror('ajaxError:' + msg.join(';'));
});
})();