[Vuejs]-Vue router navigation guard prevent url from being changed

1👍

To reject a navigation but to not reset the url to its previous state you can reject the navigation with (requires vue 2.4.0+):

next(new Error('Authentication failure'));

And if you don’t have router error handling then you need to include:

router.onError(error => {
    console.log(error);
});

See documentation for more details: https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards

0👍

Try this
history.pushState({}, null, ‘/test’) before the return next(false);

Leave a comment