I am trying to set value in to Array in Vuex Store, but caught an error
VueCompilerError: v-model cannot be used on v-for or v-slot scope variables because they are not writable.
Is there any way to realize this? (Without creating local copy of Vuex model array in component)
My component.vue template
<q-input v-for="phone, index in CompanyPhones" :key="index" v-model="phone" mask="(##) ### ## ##" stack-label label="Phone" />
My component.vue scripts
setup () {
const $store = useStore()
const CompanyPhones = computed({
get: () => $store.getters['CompanySettingsModule/getCompanyPhones'],
set: (val) => {
$store.commit('CompanySettingsModule/setCompanyPhones', val)
}
})
return { CompanyPhones, }
}
Vuex module state.ts
function state (): CompanySettingsInterface {
return {
CompanyPhones: ['', '', ''],
}
}
Vuex module mutations.ts function
setCompanyMails (state: CompanySettingsInterface, val) { state.CompanyMails = val },
Vuex module getters.ts function
getCompanyPhones (state: CompanySettingsInterface) { return state.CompanyPhones },
[vuex] do not mutate vuex store state outside mutation handlers