Clear history of`-router`when loading main menu

Asked

Viewed 126 times

0

In a PWA I’m using Vuejs and I’m having problems with the back button of the smartphone, because when I use it the PWA does what is most logical and back to the previous screen.

But I just log in to the PWA and when I use the back button it goes back to the login screen, and not just once, but at least 3 times until I actually close the PWA.

Currently the navigation is done using router.push('/nomeDaRota')

My question is: How do I so that when I log in and enter the main menu the history of vue-router clean and exit the application without going back several times on the screen??

1 answer

1


Unfortunately (or fortunately) it is not possible to change the browsing history, for safety reasons, browsers do not allow it.

If you want to seek an outline solution, you can try something during the beforeRouteEnter

beforeRouteEnter(to, from, next) {
  next(vm => {
    // tente algo aqui usando o 'to' e o 'from'
  });
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.