$.ajaxSetup({
//在请求发送之前执行,将token发送过去
beforeSend(xhr,setting){
let token = localStorage.getItem("token");
xhr.setRequestHeader("x-access-token",token);
},
//在请求完成响应返回时执行
complete(xhr, setting) {
if (xhr.responseJSON.code === 401) {
alert(xhr.responseJSON.message);
router.go('/index');
}
}
})