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){

}






posted @ 2020-11-03 17:03  爬坑之路任重而道远  阅读(1467)  评论(0)    收藏  举报