elemenui table合并单元格(总结)

<el-table :span-method="arraySpanMethod" ...></el-table>
arraySpanMethod(obj) {...}
obj为对象,其包含当前行row、当前列column、当前行号rowIndex、当前列号columnIndex四个属性。
第4行除第1列外的所有单元格
let a = 1
if (obj.rowIndex === 3 && obj.columnIndex > 0) { // 当为第四行且不为第一列
    if (obj.columnIndex === 1) { // 设置第四行第二列单元格的跨列数
        a = this.theadGroupUuid.length + 1
    } else {
        a = 0
    }
}
return [1, a]
偶数行的前两列(官网
if (rowIndex % 2 === 0) {
          if (columnIndex === 0) {
            return [1, 2];
          } else if (columnIndex === 1) {
            return [0, 0];
          }
        }
第一列除标题行外,每两行合并一次(官网)
if (columnIndex === 0) {
          if (rowIndex % 2 === 0) {
            return {
              rowspan: 2,
              colspan: 1
            };
          } else {
            return {
              rowspan: 0,
              colspan: 0
            };
          }
        }
   
   
   
   
   

猜你喜欢

转载自blog.csdn.net/guishifoxin/article/details/85694921