1 function errorCheck() { 2 window.addEventListener('error',function(error){ 3 if(error.filename){return false;}else{ 4 console.log(error.target+"资源加载失败"+":"); 5 console.log(error.target);} 6 },true); 7 window.onerror = function(message, source, lineno, colno, error) { 8 console.log("程序终止:"+message+" at "+lineno+":"+colno); 9 return true; 10 } 11 window.addEventListener('unhandledrejection',function(event){ 12 event && event.preventDefault(); 13 console.log("数据接口请求失败"); 14 },true); 15 }