//interceptors:拦截器 axios.interceptors.request.use(x => { var userinfo = window.localStorage.getItem(config.userkey); if (userinfo) { var user = JSON.parse(userinfo); x.headers.Authorization = `Bearer ${user.userToken}` } return x; }) axios.interceptors.response.use(x => { if (x.data.code != 200) { alert(`请求接口异常=>${x.data.message}`); // Vue.$message.error(x.data.message) } return x; })
标签:拦截器,interceptors,vue,userinfo,第五步,message,data From: https://www.cnblogs.com/gyp2001/p/17811208.html