router.beforeEach((to, from, next) => {
if(to.name != 'Home'){
if(localStorage.getItem('QZYtoken')){
next()
}else{
alert('请先登录')
}
}else{
next()
}
})
router.beforeEach((to,from,next) => {
const isLogin = sessionStorage.QZYtoken ? true : false
if(to.path == '/login' || to.path == '/register'){
next()
}else{
isLogin ? next() : next('/login')
}
})
路由首位两种写法
最新推荐文章于 2023-03-10 17:32:54 发布