使用vuex-persistedstate,配置是否缓存数据
emer 发布于 2021-4-8 16:23 1508 次阅读
import Vue from 'vue'; import Vuex from 'vuex'; import app from './module/app'; import exchange from './module/exchange'; import user from './module/user'; import header from './module/header'; import gbbo from './module/gbbo'; import createPersistedState from 'vuex-persistedstate'; Vue.use(Vuex); export default new Vuex.Store({ plugins: [ createPersistedState({ storage: window.localStorage, // window.localStorage paths:['app', 'exchange', 'user', 'header'] //这些页面将会缓存,未配置到里面的gbbo不会缓存到localstorage }) ], state: { // }, mutations: { // }, actions: { // }, modules: { app, exchange, user, header, gbbo } });
';