Imagine having an array declared in the data section like this:
data() {
return {
myData : [{foo:2, bar:3},{foo:4,bar:5}]
}
}
If you want to identify when the bar
property of the second
element changes, what should your watch function look like?
watch : {
myData : {
deep : true,
handler(oldVal, newVal) {
console.log("The new value is referring to the entire myData[] array, which might not be what we're looking for:", newVal);
// We also need to pinpoint the index of the modified entry in the array.
}
}
}