路由守卫 全局前置守卫 router.beforeEach((to, from,next) => { // ... if(to.fullPath=='/mine' || to.fullPath=='/detail'){ nowinfo().then(res=>{ console.log(res) if(res.code==0) { next(); }else{ next('/index'); } }) }else{ next() } // 返回 false 以取消导航 // return false })