[Vuejs]-Detect entry to parent component from child component Vue

1👍

You can use navigation guard to get the previous route and do your check.

In your parent component you can add this:

beforeRouteEnter (to, from, next) {
 // here you can save to and check it in mounted for instance
 // call next and pass a callback to access the component when it is ready
 next(parentComp => {
   parentComp.navigatedFrom = from
 })
},

And then you can access navigatedFrom from inside your parent component.

Leave a comment