[Vue3 Vuex4] 使用 vuex-persistedstate 持久化
Sonder
2022-10-31
448字
1分钟
浏览 (3.5k)
npm install --save vuex-persistedstate
import { createStore } from 'vuex'
import createPersistedState from 'vuex-persistedstate'
import App from '@/App'
import modules from '@/store'
const app = createApp(App)
const store = createStore({
modules: modules,
plugins: [createPersistedState({storage: window.sessionStorage})]
})
app.use(store)
app.mount('#app')
参考:https://byceclorets.com/vue/vue3-vuex4-vuex-persistedstate/