【发布时间】:2017-07-11 19:46:36
【问题描述】:
假设我在数据部分声明了一个数组
data() {
return {
myData : [{foo:2, bar:3},{foo:4,bar:5}]
}
}
当我更改second 元素的bar 属性时,我想知道第二个元素已更改。
我的手表功能会是什么样子?
watch : {
myData : {
deep : true,
handler(oldVal, newVal) {
console.log("New val is the entire myData[] array which is not what I want", newVal);
// I also want to know what index of the array the changed value belonged to.
}
}
}
【问题讨论】:
标签: javascript vue.js frontend