vue for循环中常见,某列数值的求和(合计)

时间:2019-06-06 16:54:49   收藏:0   阅读:4731

例:求后台返回数据
this.dataInfo 中某个字段(item.totalSum)的和,只需添加computed,然后模板中直接可以使用totalSumAll (不需要再data中声明)
computed:{
totalSumAll(){
let totalSumAll = 0;
this.dataInfo.map((item) => {totalSumAll += item.totalSum})
return totalSumAll
},
}


技术分享图片

 

原文:https://www.cnblogs.com/shuihanxiao/p/10985832.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!