路由守卫 - 全局前置守卫

router.beforeEach( ( to ,from ,next ) => { } )
to : route 即将进入的路由对象
from : route 当前正要离开的路由对象
next : Function 回调

常见操作:
next(): 进行管道中的下一个钩子
next(false): 中断当前导航
next( ./xx ): 中断当前导航,并跳转至设置好的路径

常见用途:登录验证/判断token过期与否

猜你喜欢

转载自www.cnblogs.com/vancissell/p/12913523.html