[Vuejs]-Vuex and dynamic states. Is possible?

12👍

Since your keys initially are not declared in data, Vue can’t track the changes. You need to use Vue.set to reactively add properties, see change detection caveats:

import Vue from 'vue'

const mutations = {
    changeOrAdd(state, {key, value}) {
        Vue.set(state.data, key, value)
    }
}
👤Psidom

Leave a comment