直接上代码,遍历data中prodAllPrice,并累加、算总数,总计(this.list.forEach方法实战):
//定义
let sum = 0;
this.list.forEach((item) => {
//遍历prodAllPrice这个字段,并累加
sum += item.prodAllPrice;
});
//返回
this.sum = sum;
直接上代码,遍历data中prodAllPrice,并累加、算总数,总计(this.list.forEach方法实战):
//定义
let sum = 0;
this.list.forEach((item) => {
//遍历prodAllPrice这个字段,并累加
sum += item.prodAllPrice;
});
//返回
this.sum = sum;