//全局守卫鉴权进入
router.beforeEach((to, from, next) => {
//to.path要到的路由
//to.fullPath要匹配的路由
if (to.path === '/') return next()
if (Cookies.get('token')) {
next();
} else {
next({
path: "/",
query: {
redirect: to.fullPath
}
})
}
next();
})
路由全局守卫
最新推荐文章于 2024-04-29 16:08:27 发布