I want to go back by using this.$router.go(-n). And I want to check the name of the back router to decided to go back or not. How can I get the name of back router? Please help me. Thanks.
Asked
Active
Viewed 125 times
0
-
It seems your answer is here https://stackoverflow.com/questions/53788975/vue-router-how-to-get-previous-page-url – AbdulAzeez Olanrewaju Nov 01 '19 at 08:40
-
That is not the answer I want.It just gets the name of this.$router.go(-1) from 'from'. I wanna get the name of this.$router.go(-n) like this.$router.go(-2), this.$router.go(-3) ... – Lam Nov 01 '19 at 08:56
1 Answers
0
Hi you could use beforeRouteEnter
beforeRouteEnter(to, from, next) {
next(vm => {
vm.prevRoute = from
})
},
and in paramater from you will get previous route.

Loki
- 1,064
- 2
- 26
- 55
-
Thanks for your reply. But it just gets previous route. I mean get the route of n (2,3...) step back. – Lam Nov 01 '19 at 10:32