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";
            });
        }
    }
});
 
效果

 

 

 

点击确定后跳转到登陆页
 

 

 

 
 
 
posted @ 2019-09-17 17:59  1点  阅读(2636)  评论(0编辑  收藏  举报