table组件实现首行合计(el-table, a-table)

2,848 阅读1分钟

1.需求: el-table实现首行合计

image.png

  • 说明:该合计为全局合计,字段后端返回,主要处理显示问题(之前是尾行合计)
  • 整个系统都要实现首行合计,可以把css放在app.vue文件中即可
1.在官网控制台调试

image.png

2.el-table 的实现的效果

image.png

order默认值为0,只需将表体order置为1即可移到最后,这样合计行就上移到表体上方

  ::v-deep .el-table {
    display: flex;
    flex-direction: column;
  }
  ::v-deep .el-table__body-wrapper {
    order: 1;
  }
  // 若没有固定列,以下代码可以不写
    // 将固定列放在首行
  /deep/ .el-table__fixed-body-wrapper {
     top: 96px !important; // 根据自己的项目进行微调
   }
  /deep/ .el-table__fixed-footer-wrapper {
    z-index: 0;
    top: 48px; // 根据自己的项目进行微调
  }

2.字节跳动开源ui组件库 arco.design 中a-table实现首行合计

  • 尾行合计 image.png

  • 首行合计

image.png

  • 注意:haeder和body类名相同
  • 实现:
.arco-table-content .arco-scrollbar:nth-child(2) {
  order: 1 !important;
}

参考1:blog.csdn.net/qq_44170108…

参考2