0👍
With vuex, you want to be using actions and mutations.
setLanguage: (e, index) => {
let name = e.target.value.trim()
this.$store.dispatch('setLanguage', {name, index}) //dispatches a vuex action
}
Then define an action:
setLanguage({ commit }, payload) {
commit('setLanguage', payload) //commits a vuex mutation
}
And finally a mutation:
setLanguage(state, payload) {
state.languages[payload.index].name = payload.name
}
see the vuex documentation on this: https://vuex.vuejs.org/guide/actions.html
Source:stackexchange.com