Clear vue-router history when loading main menu

0

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

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

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

My question is: How do I make sure that when I log in and enter the main menu the history of vue-router wipe and exit the application without getting backstage several times on the screen ??

    
asked by anonymous 12.04.2018 / 16:41

1 answer

1

Unfortunately (or fortunately) you can not change the browsing history, for security reasons browsers will not allow it.

If you want to find a contour solution, you can try something during beforeRouteEnter

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