Vue3学习笔记2——路由守卫
路由守卫
全局
router.beforeEach((to, from, next) => {})router.afterEach((to, from, next) => {})
组件内守卫
beforeRouteEnter((to, from, next) => {})beforeRouteUpdate((to, from, next) => {})beforeRouteLeave((to, from, next) => {})
路由独享
beforeEnter((to, from, next) => {})
参数详解
| 参数 | 描述 |
|---|---|
| to | 跳转到哪个路由对象 |
| from | 要离开的路由对象 |
| next | 一个方法,可以接收参数。这个方法必须调用,不使用无法跳转 |
next():要to过去next(false):可以不通过,中断跳转next('/'):不让过,可以去另一个地方
