前置路由守卫vue
router.beforeEach((to, from, next) => {
if (!to.query.code) {
next({
path: to.path,
query: { code: "hm" },
});
} else {
next();
}
});
前置路由 一般使用router.beforeEach
有三个参数
to:去哪个页面;from:从哪个页面来 ;next: 放行函数 next():放行 , next(false):不放行
我这里的例子是写死的状态

浙公网安备 33010602011771号