element table表格合并

    //计算同列中相同元素,并放入list中
getList(data) {
      for (var i = 0; i < data.length; i++) {
        console.log(data[i])
        if (i === 0) {
          this.list.push(1);
          this.number = 0
        } else {
          // 判断当前元素与上一个元素是否相同
          if (data[i].equipment === data[i - 1].equipment) {
            this.list[this.number ] += 1;
            this.list.push(0);
          } else {
            this.list.push(1);
            this.number = i;
          }
        }
      }
      console.log(this.list);
    }
//处理合并方法
objectSpanMethod({row, column, rowIndex, columnIndex}) {
      if (columnIndex === 0) {
        const _row = this.list[rowIndex];
        const _col = _row > 0 ? 1 : 0;
        return {
          rowspan: _row,
          colspan: _col
        }
      }
    }

版权声明:本文为weixin_44662304原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。