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


例:求后台返回数据
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
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3