VUE 動態注入路由白屏,再次刷新才顯示頁面問題


router.addRoutes(result);
next({...to,replace:true}) //划重點 一定需要這一句 還是不行

//首頁重定項
 let path=首頁

self.$router.push(

 {
path: path,
});

//重定向 發現頁面刷新 都會回到首頁

動態添加添加路由
try(){
if(){
 
        
router.addRoutes(result);
next({...to,replace:true})
 
        

}else{
 
        
if(to.matched.length===0){//判斷是否有路由 在追加一次
var c= getAsyncRoutes(parentRoute);
router.addRoutes(c);
next({...to,replace:true})
}

}catch(error){

}







免責聲明!

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



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