1.vuex 状态持久化插件 —— vuex-persistedstate
npm install --save vuex-persistedstate
2.在vuex的index.js文件中
import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from 'vuex-persistedstate'
3.使用持久化插件
export default new Vuex.Store({
state: {
car: []
},
mutations: {
},
getters: {
},
actions: {},
modules: {},
plugins: [createPersistedState()]
});