1 回答
TA贡献1826条经验 获得超6个赞
登录获取token
this.$http.get(Util.DataInterface + '/api/auth', {
params: quseDataNow,
emulateJSON: true
}).then((response) => {
localStorage.setItem('token', response.data.data.token);
}, (response) => {
console.log("error: ", response);
});
获取到token以后每次请求接口都带上
headers: {
Authorization: localStorage.getItem("token")
},
this.$http.get(Util.DataInterface + '/api/ranking/platform', {
headers: {
Authorization: localStorage.getItem("token")
},
params: quesDataNow,
emulateJSON: true
}).then((response) => {
this.tableList = response.data;
$('#sortTable').DataTable().destroy();
this.tableLoad();
}, (response) => {
// error callback
if (response.status === 401) {
Util.init();
}
});
添加回答
举报