關於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