方法
ストアの永続化にはvuex-persistedstateを使い、ストアのインスタンス生成時のplugins指定でcreatePersistedState()
にオプションとしてpaths
を付ける。
https://github.com/robinvdvleuten/vuex-persistedstate
import createPersistedState from "vuex-persistedstate";
const store = new Vuex.Store({
// ...
plugins: [createPersistedState({
paths: ['※パス']
...
})],
});
※ パスはステート内のパスになります。
例:namespaced: true
でモジュールとしてUser.jsを作成した場合は'User'
オプションの詳細はAPI説明で確認ください。