[Vuejs]-How to stop router from a component?

1👍

You should be using the router’s Navigation Guards (https://router.vuejs.org/en/advanced/navigation-guards.html) and register your guard on the

router.beforeEach((to, from, next) => {
  // ...
})) method.

Then you just need to call next(false) to cancel the navigation after checking that your component is dirty.

Leave a comment