基本使用规则
router.beforeEach((from,to,next) => {})
其中,from代表要离开的路由参数,to代表要前往的路由参数,next跳转方法

next(),从from跳转到to
next(false)拦截跳转,留在from
next('path')或next(path:'path'),从from跳转到path
每次路由跳转后都会调用路由守卫,所以在路由守卫中一定要写清楚判断条件,否则会形成死循环

基本使用规则
router.beforeEach((from,to,next) => {})
其中,from代表要离开的路由参数,to代表要前往的路由参数,next跳转方法
next(),从from跳转到to
next(false)拦截跳转,留在from
next('path')或next(path:'path'),从from跳转到path
本文标题:路由拦截(守卫)
本文链接:https://www.haomeiwen.com/subject/cmvjprtx.html
网友评论