I wanted to store previous page although users refresh the page. I used
beforeRouteEnter(to, from, next) {
next(vm => {
vm.prevRoute = from
})
},
to store this.prevRoute.path
into Data. However, I realized once I refresh the current page, my path is gone. I wonder if there is anyway I can restore the previous page.
CodePudding user response:
users refresh the page, for this purpose you can either use
- Local Storage
- Cookies
To give an example, you can do something like this
// To save the path
localStorage.setItem("prevRoutePath", thePathYouWant);
// To get the saved path
const prevPath = localStorage.getItem("prevRoutePath") ?? "fallback"; // You can get this whenever you want.