vuejs怎么watch對象里某個屬性的變化
vuejs怎么watch對象里某個屬性的變化
慕運維8079593
2019-03-18 12:12:30
TA貢獻1851條經(jīng)驗 獲得超3個贊
用計算屬性,返回值是這個列表值相加
computed: { countTotal: function () { let total = 0; this.items.forEach(function (item) { total += item.count }) return total } }
監(jiān)聽用 watch選項
watch: { items: { handler: function () {}, deep: true } }
對象要深復(fù)制,默認(rèn)是淺復(fù)制
舉報