when doing the vue project, I wrote the following code. The page is stuck and there is an endless loop. Maybe there is something wrong with the logic. The boss gives reason
.related codes
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
})
}
})
}