使用计算属性做的...在data中不需要定义totalMoney
computed: {
totalMoney: function () {
let results = 0;
this.productList.forEach( item => {
if (item.checked) {
results += item.productPrice*item.productQuentity
}
})
return results
}
},
computed: {
totalMoney: function () {
let results = 0;
this.productList.forEach( item => {
if (item.checked) {
results += item.productPrice*item.productQuentity
}
})
return results
}
},
2017-03-11