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

 

 

 

點擊確定后跳轉到登陸頁
 

 

 

 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM