March 2018
Beginner to intermediate
344 pages
7h 7m
English
We can also hook into beforeRouteLeave to perform actions whenever we're navigating away from a route. As we're already on this route within the context of this hook, we have access to the component instance. Let's look at an example:
beforeRouteLeave(to, from, next) { console.log(`I'm called before leaving the route!`) console.log(`I have access to the component instance, here's proof! Name: ${this.name}`); next(); }
Once again, we have to call next in this instance.
Read now
Unlock full access