在虚拟机创建中使用"监视"部分:
var vm = new Vue({
el: 'body',
data: {
items: []
},
computed: {
item_length: function () {
return this.battle_logs.length;
}
},
watch: {
items: {
handler: function () {
console.log('caught!');
},
deep: true
}
}
});
或者查看计算长度属性:
vm.$watch('item_length', function(newVal, oldVal) {
console.log('caught!');
});