tree数据结构来计算跨行
const data = [{ 'id': '92838232090121', 'psId': '8832878989329', 'psName': '无锡火电厂01', 'mpId': '7928810012121', 'mpName': 'SBR法工艺流程', 'area': 90.1, 'equip': [{ 'equipId': '1212121', 'equipName': '脱硫泵', 'pollutantCodes': [{ 'pollutantype': 'g2008', 'pollutantName': 'SO2', 'producfactor': '12.12', 'effictRate': '50' }] }, { 'equipId': '1212121', 'equipName': '脱硫泵', 'pollutantCodes': [{ 'pollutantype': 'g2008', 'pollutantName': 'SO2', 'producfactor': '12.12', 'effictRate': '50' }, { 'pollutantype': 'g2003', 'pollutantName': 'NO', 'producfactor': '13.12', 'effictRate': '60' } ] }, { 'equipId': '1212132', 'equipName': '脱硫泵AA', 'pollutantCodes': [{ 'pollutantype': 'g2008', 'pollutantName': 'SO2', 'producfactor': '12.12', 'effictRate': '50' }, { 'pollutantype': 'g2003', 'pollutantName': 'NO', 'producfactor': '13.12', 'effictRate': '60' }, { 'pollutantype': 'g2005', 'pollutantName': 'CO', 'producfactor': '12.12', 'effictRate': '89' } ] } ] }] const deepGetColspan = (node) => { let rowspan = 0 const children = node.equip || node.pollutantCodes node.rospan = 1 if (children && children.length > 0) { children.forEach(child => { rowspan += deepGetColspan(child) }) node.rospan = rowspan } return node.rospan } data.forEach(node => { deepGetColspan(node) })