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')
}
})
路由首位两种写法
最新推荐文章于 2024-02-23 11:02:50 发布