thisfloorElvTotalNum =thispatrolStatisticsListreduceaccumulator currentValue = accumulator + currentValuevalue 0; 保留小数点后1位
To keep the decimal places to one, you can use the toFixed() method after calculating the total. Here's an example:
this.floorElvTotalNum = this.patrolStatisticsList.reduce((accumulator, currentValue) => accumulator + currentValue.value, 0).toFixed(1);
This will convert the result to a string with one decimal place.
原文地址: https://www.cveoy.top/t/topic/iUjf 著作权归作者所有。请勿转载和采集!