LoginSignup
0
1

More than 3 years have passed since last update.

Vuexでストア内容の永続化を部分的に行う

Last updated at Posted at 2020-05-13

方法

ストアの永続化には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説明で確認ください。

参考にしたページ

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1