Answer the question
In order to leave comments, you need to log in
How to work with plugins in Vuex?
I can't really understand how to work with vuex plugins. Not very much info. Actually, I have a task so that a certain state is not reset to zero when the page is reloaded. I decided to use vuex-persistedstate for this.
The docs provide an example of using the plugin. How to tell the plugin what specific state to synchronize? And is it possible to tell him from some action that now you need to overwrite / delete something from localstorage?
const store = new Store({
// ...
plugins: [
createPersistedState({
storage: {
getItem: key => Cookies.get(key),
setItem: (key, value) => Cookies.set(key, value, { expires: 3, secure: true }),
removeItem: key => Cookies.remove(key)
}
})
]
})
Answer the question
In order to leave comments, you need to log in
How to tell the plugin what specific state to synchronize?
const store = new Store({
// ...
plugins: [
createPersistedState({
storage: {
getItem: key => Cookies.get(key),
setItem: (key, value) => Cookies.set(key, value, { expires: 3, secure: true }),
removeItem: key => Cookies.remove(key)
}
})
]
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question