objectSpanMethod({ row, column, rowIndex, columnIndex }) { const length = this.newlist[this.saveindex].data.newTable.length - this.newlist[this.saveindex].data.tag_list_all.length // 新增:处理前两行前两列的合并 if (rowIndex < length && columnIndex < 2) { if (columnIndex === 0) { return { rowspan: 1, colspan: 2 // 合并两列 } } else { return { rowspan: 0, colspan: 0 // 隐藏第二列的其他单元格(已被第一列合并) } } } if (columnIndex === 0 && rowIndex >= length) { const _row = this.flitterData( this.newlist[this.saveindex].data.newTable ).one[rowIndex] const _col = _row > 0 ? 1 : 0 return { rowspan: _row, colspan: _col } } }, flitterData(arr) { const spanOneArr = [] let concatOne = 0 arr.forEach((item, index) => { if (index === 0) { spanOneArr.push(1) } else { if (item.p_value === arr[index - 1].p_value) { // 第一列需合并相同内容的判断条件 spanOneArr[concatOne] += 1 spanOneArr.push(0) } else { spanOneArr.push(1) concatOne = index } } }) return { one: spanOneArr } },
标签:el,const,index,rowIndex,单元格,spanOneArr,length,table,row From: https://www.cnblogs.com/ylblogs/p/18158042