new Vue({
el: "#app",
data: {
target: {
list: [],
},
},
watch: {
"target.list": {
handler(newVal, oldVal) {
},
deep: true,
},
}
});
给target的list属性增加侦听器,需要在watch中使用字符串的写法 "target.list" 来标记侦听的内容
handler
当list改变时被调用,设置deep
为true,给list增加深度监听