npm install --save vuex-persistedstate
import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";
import { Auth } from "./auth";
import { Cart } from "./cart";
import { Products } from "./products";
Vue.use(Vuex);
export default new Vuex.Store({
modules: {
auth: Auth,
cart: Cart,
products: Products,
},
plugins: [
createPersistedState({
//주목! : 여기에 쓴 모듈만 저장됩니다.
paths: ["cart","auth"],
}),
],
});
출처: https://uxgjs.tistory.com/207
npm ::
https://www.npmjs.com/package/vuex-persistedstate
github ::
https://github.com/robinvdvleuten/vuex-persistedstate#readme
안녕하세요 혹시
vuex안에 있는 state가 action 이나 mutations으로 변경되었을 때도 저장이 되시나요?