浏览代码

feat: 接口报错弹框

Jinyao 5 年之前
父节点
当前提交
50f9c65a5b
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      src/utils/axios.ts

+ 8 - 0
src/utils/axios.ts

@@ -40,6 +40,14 @@ _axios.interceptors.response.use(
       window.location.href = '/';
       return;
     }
+    if (response.data.code >= 500) {
+      ElMessage({
+        type: 'error',
+        showClose: true,
+        message: '接口出错,错误信息:' + response.data.msg,
+      })
+      return;
+    }
     return response.data.data;
   },
   (error) => {