数组对象中某个值累加reduce

当美术组对象中的长度自动累加
数组如下

let  tableData= [{
latitude: 30.509798872589958
lineLength: 0
longitude: 118.21164339084336
pointDepth: 0
positionIndex: 1},
{
latitude: 30.509798872589958
lineLength: 0
longitude: 118.21164339084336
pointDepth: 0
positionIndex: 1}]
       // 计算表单管线长度
        let count = tableData.reduce((total, cur) => {
          return total + Number(cur.lineLength);
        }, 0);
        that.addForm.lineLength = count;

你可能感兴趣的:(js,vue.js,前端,javascript)