Patex
Patex

Reputation: 67

Vue.set() on nested array properties

i've been trying to trigger Vue DOM updates by updating an array the old way and it obviously wont do it because of the ceveats on Vue detecting object/array changes. I dont know how to access my nested array properties by using Vue.set. Normally i would access and assign my property like this (by the way this is a state in Vuex):

state.timelines[0].events[0].item.info = payload.info

I dont know how to access and assign that property with .set, i've tried a few combinations but they failed to work. Thanks.

Upvotes: 1

Views: 5423

Answers (1)

Patex
Patex

Reputation: 67

Solution: when trying to alter an object property, even if its deep in nested arrays, just use: Vue.set(arrayA[indexA].arrayB[indexB].object('objectPropertyName', newValue))

If dealing with arrays use: Vue.set(array, arrayIndex, newValue).

Upvotes: 2

Related Questions