修bug
This commit is contained in:
@@ -53,9 +53,7 @@ http.interceptors.response.use(
|
|||||||
if (error.response.status === 401) {
|
if (error.response.status === 401) {
|
||||||
// 清除token并重定向到登录页
|
// 清除token并重定向到登录页
|
||||||
localStorage.removeItem('jwt_token');
|
localStorage.removeItem('jwt_token');
|
||||||
// 这里需要访问router,但http.js是纯工具文件,不应直接依赖Vue Router实例
|
window.location.href = '/login';
|
||||||
// 可以在main.js的全局错误处理或组件中处理401错误
|
|
||||||
// 例如:window.location.href = '/login';
|
|
||||||
}
|
}
|
||||||
} else if (error.request) {
|
} else if (error.request) {
|
||||||
// 请求发出但没有收到响应
|
// 请求发出但没有收到响应
|
||||||
|
|||||||
Reference in New Issue
Block a user