[Vuejs]-Stay on same page if condition met in vue router

3👍

You need to add next(false) in your conditional block to abort navigation. You can found more info about next here.

if ((from.path === '/agencies' || to.path.match(/profile/agencies/)) && response.data.verified === 'yes' && response.data.category === "C" ) {
      //Stay on the same page
      next(false);
}

You can also use next(error) instead of next(false) in combination with router.onError(callback) to show some error.

Leave a comment