// 合并 objectSpanMethod({ row, column, rowIndex, columnIndex }) { let $rowIndex = rowIndex; let fields = ["rectificationNo"]; //需要合并的字段 let cellValue = row[column.property]; let data = this.tableData; // 表格的所有数据, if (cellValue && fields.includes(column.property)) { let prevRow = data[$rowIndex - 1]; let nextRow = data[$rowIndex + 1]; if (prevRow && prevRow[column.property] === cellValue) { return { rowspan: 0, colspan: 0 }; } else { let countRowspan = 1; while (nextRow && nextRow[column.property] === cellValue) { nextRow = data[++countRowspan + $rowIndex]; } if (countRowspan > 1) { return { rowspan: countRowspan, colspan: 1 }; } } } },
在el-table 表格上添加:span-method="objectSpanMethod"