1第一步设置token
getAction("/user/info").then(res=>{ Vue.ls.set('Set_Token',res.data.access_token) })
2第二步
设置token
serviceXing.interceptors.request.use(function (config) { // Do something before request is sent //window.localStorage.getItem("accessToken") 获取token的value const token = Vue.ls.get('Set_Token'); /* var person = new Object(); person.user='X-CSRF-Token'*/ if (token) { //将token放到请求头发送给服务器,将tokenkey放在请求头中 config.headers['X-CSRF-Token'] =token //也可以这种写法 // config.headers['accessToken'] = Token; return config; } }, function (error) { // Do something with request error return Promise.reject(error); });