Vuex数据默认是存储在内存中的,当然我们也可以将它存储在Local Storage,也可以指定某些数据存储在Local Storage 这样我们就用到了Vuex持久化插件vuex-persistedstate
安装vuex-persistedstate插件
npm install vuex-persistedstate --save
案列:
import axios, { Axios } from 'axios';
import { createStore } from 'vuex'
import ListAModule from '../views/ListAModule.js'
import ListBModule from '../views/ListBModule.js' //导入模块
import createPersistedState from 'vuex-persistedstate'
const store = createStore({
    plugins:[createPersistedState({
        reducer:(state)=>{
            return{
                name:state.ListAModule.name //将ListAModule模块中的name持久化到Local Storage中
            }
        }
    })],
    modules: {
        ListAModule,  //ListAModel:ListAModel简写  注册ListAModel模块
        ListBModule   //ListBModel:ListBModel简写  注册ListBModel模块
    }
});
export default store



















