layui token 过期 重新登陆

这个方法你要全局设置
 
 
//jquery全局配置
$.ajaxSetup({
    cache: false,
    crossDomain: true,  
    headers :{'Authorization':token},
    complete: function (xhr) {
        console.log(xhr)
        if(xhr.responseJSON&&xhr.responseJSON.status==401) {
            console.log(xhr.responseJSON);
            layer.alert('权限不足,请重新登陆', {
                icon: 5,
                title: "提示"
            },function() {
                window.parent.location.reload(); //刷新父页面
                window.parent.location.href="./index.html";
            });
        }
    }
});
 
效果
点击确定后跳转到登陆页
 
 
 
 

猜你喜欢

转载自www.cnblogs.com/guangzhou11/p/11535872.html
今日推荐