robinvdvleuten / vuex-persistedstate

💾 Persist and rehydrate your Vuex state between page reloads.
https://npm.im/vuex-persistedstate
MIT License
5.77k stars 378 forks source link

Vue3.0 uses Vuex 4.0 to refresh the page after data loss #405

Closed anpabupa closed 3 years ago

anpabupa commented 3 years ago

export interface StateInterface { // Define your own store structure, using submodules if needed // example: ExampleStateInterface; // Declared as unknown to avoid linting issue. Best to strongly type as per the line above. system: SystemStateInterface setting: { route: RouteStateInterface theme: ThemeStateInterface } }

export default store(function (/ { ssrContext } /) { const Store = createStore({ modules: { system, setting, },

strict: false,
plugins: [
  createPersistedState({
    storage: window.sessionStorage,
    reducer: ({ system, setting }) => ({ system, setting }),
  }),
],

})

return Store })

------My sessionstorage has values but the refresh page state is still reset

Excuse me, is there something wrong with the method I used

atom-git commented 3 years ago

use this.$store.state. system to get the value, Through a morning time analysis,found only in this model can get the correct result