Hi I'm making a webpage based on Vue , but I'm in trouble now. I initially used router.go(-1) to prevent access through the address (ex: ../client/mypage ->../admin/mypage ) and to redirect to the previous page, but it didn't work because the page itself was refreshed. (In my opinion,router history stack was empty)
So, what I found is window.history.go(-1) , but it didn't work either even though its length was greater than 1.
What's the problem and how should I solve it?
mounted(){
if (this.auth) { // when you access through address, check the authority
this.$router.go(-1); //doesn't work
window.history.go(-1); //doesn't work either
}
}
Try with this.
mounted(){
if (!this.auth) { //If not authenticated
window.history.back();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.