mounted() {
console.log("aaa") let _this = this this.$router.beforeEach(function (to,from,next) { if(to.meta.auth) { if(window.localStorage.getItem('user')) { console.log('路由设置了守卫,但是已经登录了'); next() } else { console.log('路由设置了守卫,但是我还没有登录') console.log(_this.$router, 'sfafasdfasdf') _this.$router.push({path:'/login'}) next({ path: to.path, }) } } else { console.log("路由没有设置守卫"); next({ path: to.path }) } })
}
相关分类