文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit e03f0529 by 李严凡

全局请求登录拦截跳转

parent 25aced6a
......@@ -32,6 +32,16 @@ axios.interceptors.response.use(function (response) {
// 对响应错误做点什么
return Promise.reject(error)
})
//添加请求拦截器,每次请求设置都请求cookie信息
axios.interceptors.request.use(function(config){
let token = localStorage.getItem("userId")
if(!token){
window.location.href = '/#/login'
}
return config
},function(error){
return Promise.reject(error)
})
Vue.use(VueAxios, axios)
Vue.use(ElementUI)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment