[Vuejs]-Vue3 disable next page & prev page in the browser when inside the same route path

1👍

Here’s a high-level example using Vue Router:

router.beforeEach((to, from, next) => {
  if (to.params.id && from.params.id) {
    if (to.params.id !== from.params.id) {
      next(); // Allow navigation to the next page within the route
    } else {
      next(false); // Block navigation to the same page within the route
    }
  } else {
    next(); // Allow navigation to other routes
  }
});

0👍

I found that

this.$router.replace({ path: '/your-route' });

instead of

router.push

solved my problem.

👤lgtits

Leave a comment