[Vuejs]-Remember filled values while navigation in vue router

0👍

you can use beforeRouteLeave hook to save the data in Vuex store. Here’s the example.

beforeRouteLeave (to, from, next) {
   //Assuming you're storing your data in `configData`

   store.dispatch('saveConfigData', configData)
   //You can create a action (saveConfigData) in your store.
  } 

Then when component mounts, you can use this data from store via getter to set in page/input fields.

mounted() {
this.data = <datafromstore>
}

And you can clear your store values for config data once config form is submitted successfully.

Leave a comment