关于beforeRouteEnter中的next()


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周期之后。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM