vue.js - Saving state on back button press in vue-electron -


i want make desktop app in vue-electron. new both vue.js , electron. having problems while managing state.

when click on login button https://cloudup.com/cfl9mty6cnn send data i.e sessionid , username next screen https://cloudup.com/c76fml8ogbf , on screen display these props https://cloudup.com/csahnc6z04j using code https://cloudup.com/cdr0f6qyt-3 go third screen https://cloudup.com/c0f1ztx8qu3 , come data disappears https://cloudup.com/ctfw32dxera

i going second screen using router.go(-1) https://cloudup.com/cvpxk4gsirx

the vue-router documentation https://router.vuejs.org/en/essentials/navigation.html says “router.push method pushes new entry history stack, when user clicks browser button taken previous url.” , router.go(n) "this method takes single integer parameter indicates how many steps go forwards or go backwards in history stack"

however in case, lifecycle hooks called again when go history stack. mean when come previous page component created again , not popped stack. don’t want refresh / reload page on button.

you need send data third screen,too.

instead of

<route-link to="third_screen"></router-link> 

you need write,

<router-link :to="{ path: 'third_screen', params: { session_id: this.session_id, username:this.user_name}}">user</router-link> 

and instead of router.go(-1) need send data params again second screen using router.push() method.

but won't suggest above method need pass same data params routes.

you should have @ vuex.

vuex state management pattern + library vue.js applications. serves centralized store components in application, rules ensuring state can mutated in predictable fashion.

you should store session id cookie instead of passing props.

update

also have @ <keep-alive></keep-alive>.

reference


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -