vuex-persistedstate插件的安装和使用
安装
npm install vuex-persistedstate --save
在store.js中引入
import Vue from 'vue';
import Vuex from 'vuex';
//Add this line
import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex);
export default new Vuex.Store({
//Add this line
plugins: [createPersistedState()],
state: {
lists: [],
},
mutations: {
addItem(state,value){
state.lists.push(value)
},
},
actions: {
},
});
原文链接:https://blog.csdn.net/Jane_3210/article/details/88309153