How can I trigger an update when altering part of an object found by index in an array?
The docs show how to alter the value of an array:
As long as you call set() once to set the object (with the property you are going to update) in the array, Vue will react to changes in the object's properties. Here's an example that has one array of objects initialized in our app's data, and another array of objects manually set (with Vue.set()) when mounted. Clicking the button updates a property on one object in each of those arrays, and Vue reacts. Note that the set() call that happens in mount() could really happen anytime.
https://codepen.io/jordan-kalosal/pen/VrwjoR
new Vue({
el: "#app",
data: {
arr: [
{
property: 'OBJ1 Prop'
},
{
property: 'OBJ2 Prop'
}
],
setLater: false
},
mounted() {
this.$set(this, 'setLater', [
{
property: 'setLater OBJ1 Prop'
},
{
property: 'setLater OBJ2 Prop'
}
])
},
methods: {
_updateObjProps() {
this.arr[0].property = (new Date()).toString();
this.setLater[0].property = (new Date()).toString();
}
}
})