beforeRouteEnter(to,from, next){

console.log(this)   //undefined

next(vm => {

console.log(vm)})

}

 1 if (token) {
 2         if (router.options.isAdd) { //判断是否已经添加动态路由
 3             next();
 4         } else {
 5             getMenuData(to, next);
 6         }
 7         next()   //这里的next()一定不能忘!
 8     } else {
 9         if (to.path === '/login') { // 如果是登录页面的话,直接next()
10             next();
11         } else {
12             next({
13                 path: '/login'
14             });
15         }
16     }

next()里的内容执行时机在组件mounted周期之后。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-28
  • 2021-04-27
  • 2021-09-23
  • 2021-06-18
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2021-12-13
  • 2021-09-18
  • 2021-09-21
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案