new Vue({
el: '#demo',
data: {
things: [{foo:1}, {foo:2}]
},
watch: {
things: {
handler: function (val, oldVal) {
alert('a thing changed')
},
deep: true
}
},
methods: {
change: function (item) {
console.log(item)
//item.a = 2
this.$set('item.a',2)
//item.a属性并无变化,应该怎么样赋值?
}
}
})
具体的看下嘛代码调试
改成
官网深入响应式原理