From b38235902bc6c4209e062d3d59f4b7b7ca030b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=80=82C?= <961080479@qq.com> Date: Thu, 1 Jul 2021 04:25:20 +0000 Subject: [PATCH] =?UTF-8?q?!6=20FIX=20response=20=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E5=99=A8=20=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=97=A0=E5=93=8D?= =?UTF-8?q?=E5=BA=94=20*=20FIX=20response=20=E6=8B=A6=E6=88=AA=E5=99=A8=20?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=97=A0=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index bf5e45d1..368eef67 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -22,16 +22,27 @@ axios.interceptors.response.use( return response; }, (error) => { - if(error.response.status == 404){ + if (error.response) { + if (error.response.status == 404) { + ElNotification.error({ + title: '请求错误', + message: "Status:404,正在请求不存在的服务器记录!" + }); + } else if (error.response.status == 500) { + ElNotification.error({ + title: '请求错误', + message: "Status:500,服务器发生错误!" + }); + } else { + ElNotification.error({ + title: '请求错误', + message: `Status:${error.response.status},未知错误!` + }); + } + } else { ElNotification.error({ title: '请求错误', - message: "Status:404,正在请求不存在的服务器记录!" - }); - } - if(error.response.status == 500){ - ElNotification.error({ - title: '请求错误', - message: "Status:500,服务器发生错误!" + message: "请求服务器无响应!" }); }