全局路由守卫 在router下的index.js中使用 // 全局进入路由的守卫函数 // to:要进入的路由 // from:从哪个路由来 // next:是一个函数,必须要调用它,否则程序就会阻塞 router.beforeEach((to,from,next)=>{ console.log(to) next() }) // 全局离开的路由函数,无next函数 router.afterEach((to,from)=>{ console.log(to) }) 组件内路由守卫