flitterData (arr, name) { let spanOneArr = [] let concatOne = 0 arr.forEach((item, index) => { if (index === 0) { spanOneArr.push(1) } else { if (item[name] === arr[index - 1][name]) { spanOneArr[concatOne] += 1 spanOneArr.push(0) } else { spanOneArr.push(1) concatOne = index } } }) return { one: spanOneArr, } }, mergeRows ({ row, column, rowIndex, columnIndex }) { if (columnIndex === 0) { const _row = this.flitterData(this.tableData, 'deptName').one[rowIndex] const _col = _row > 0 ? 1 : 0 return { rowspan: _row, colspan: _col, } } else if (columnIndex === 3) { const _row = this.flitterData(this.tableData, 'deptName1').one[rowIndex] const _col = _row > 0 ? 1 : 0 return { rowspan: _row, colspan: _col, } } else if (columnIndex === 6) { const _row = this.flitterData(this.tableData, 'deptName2').one[rowIndex] const _col = _row > 0 ? 1 : 0 return { rowspan: _row, colspan: _col, } } },
标签:index,const,elementui,rowIndex,合并,spanOneArr,动态,col,row From: https://www.cnblogs.com/tap819/p/18513137