I need to replace some array items by index in vuex nuxtjs:
changeTicket(state, value) {
// 1 - Vue.set(state.tickets, value.index, value.numbers)
// 2 - state.tickets[value.index] = value.numbers
}
Im trying 2 variants, in first i have an error = [vuex] do not mutate vuex store state outside mutation handlers., in second im lost reactivity.
In component, im sending new array after click:
setNumber(num) {
const vResult = this.numbers;
if(vResult.includes(num)) {
vResult.splice(vResult.indexOf(num), 1)
} else {
if(vResult.length >= this.options[this.game].max) return;
vResult.push(num)
}
this.$nextTick(() => {
this.$store.commit("games/changeTicket", {
numbers: vResult,
index: this.index
})
})
},
Arrays example:
[
[1,2,3,4,5],
[2,5,61,21],
...
]