在vuejs router文档中,
router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.requiresAuth)) {
if (!auth.loggedIn()) {
next({
path: '/login',
query: { redirect: to.fullPath }
})
} else {
next()
}
} else {
next()
}
})
这段代码中的auth.loggedIn()这个方法应该写在那里?
还有就是这个query字段有什么用,没有也是可以的啊?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
上面这个方法是自定义的,判断有没有登录用的。
to.fullPath是当前页的路由地址。query是为了登录成功之后可以根据query中的内容跳转回原来的路由(页面)。