I want to get previous page link or url in vue-router
. Like a this. How to do it?
const link = this.$router.getPrevLink(); // function is not exist?
this.$router.push(link);
Near concept is this.$router.go(-1)
.
this.$router.go(-1);
I want to get previous page link or url in vue-router
. Like a this. How to do it?
const link = this.$router.getPrevLink(); // function is not exist?
this.$router.push(link);
Near concept is this.$router.go(-1)
.
this.$router.go(-1);
All of vue-router's navigation guards receive the previous route as a
from
argument ..As an example you could use
beforeRouteEnter
, an in-component navigation guard, to get the previous route and store it in your data ..Then you can use
this.prevRoute.path
to get the previous URL.