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

posted @ 2019-10-27 13:48  王二疯  阅读(3146)  评论(0编辑  收藏  举报