VUE实现登陆而后跳转到原来的页面

能够在路由里面设置须要登陆的界面,判断下没有登陆就跳转到登陆界面,登陆了就不用登陆,这里用的是一个存储的session

router.beforeEach((to, from, next) => {
if(to.matched.some( m => m.meta.auth)){
if(sessionStorage.getItem('isLogin')){
next()
}else{
next({path:'/login',query:{url: to.fullPath} })
}
}else{
next();
}
})this

这里是判断是否登陆url

this.$router.push(this.$router.currentRoute.query.url)这里的代码能够直接跳转到须要登陆的界面router

相关文章
相关标签/搜索