Open sleepyShen1989 opened 1 year ago
// Vue错误处理 app.config.errorHandler = (err) => { navigator.sendBeacon(url, {error: error.message, text: 'vue运行异常' }) } // 错误事件监听 window.addEventListener('error', (error) => { if (error.message) { navigator.sendBeacon(url, {error: error.message, text: 'js执行异常' }) } else { navigator.sendBeacon(url, {error: error.filename, text: '资源加载异常' }) } }, true) // 请求错误监听 axios.interceptors.response.use( (response) => { if (response.code == 200) { return Promise.resolve(response); } else { return Promise.reject(response); } }, (error) => { navigator.sendBeacon(url, {error: error, text: '请求错误异常' }) } );
代码片段
常见错误捕获