Answer the question
In order to leave comments, you need to log in
How to pass the changed data of a specific store object to the component from vuex?
Good afternoon.
There is an array of elements in the store, on the basis of which the list is built. Each list item has a state switch for the specific item in that list. The list id is passed to the radio button. When the switch is triggered, I will dispatch the data to the store. The
getter to receive looks like thisthis.$store.dispatch('handler', payload)
getState: state => id => {
return state.listings.find(el => el.id == id).is_edited //возвращает true или false
}
this.$store.getters.getState(this.item.id)
Answer the question
In order to leave comments, you need to log in
Try replacing the mutation with this:
startMutation(state, data) {
const index = state.listings.findIndex(item => item.id === data.id)
state.listings.splice(index, 1, {...state.listings[index], is_edited: true})
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question