Reputation: 861
I need to use dictionary as one of my store variables, but It's not reactive like array, what is the best practice to solve this? I've created minimal example:
https://codesandbox.io/s/vuex-store-forked-ko3md?file=/src/App.vue
Upvotes: 2
Views: 1753
Reputation: 7729
In order to add new reactive props, instead of using direct assignment, you should use the Vue.set()
method:
ADD_ITEM(state, { key, value }) {
Vue.set(state.dict, key, value)
}
For a more in dept understanding of Vue reactivity you should read the official docs: https://v2.vuejs.org/v2/guide/reactivity.html
Upvotes: 6