ajax登录超时页面刷新

362 阅读1分钟
$.ajaxSetup({
    contentType:"application/x-www-form-urlencoded;charset=utf-8",
    complete:function(XMLHttpRequest,textStatus){
    },
    statusCode: {
        419: function() {
            alert('登陆超时,请重新登陆');
            location.reload(window.location.href);
        }
    }
});

vue登录超时页面刷新

axios.interceptors.response.use(function (response) {
    return response;
},function (error) {
    if (error.response.status == 419){
        alert('登陆超时,请重新登陆');
        location.reload(window.location.href);
    }
})