0


【前端vue+elemenui】el-table根据表格数据设置整行样式或单元格样式

首先需要了解俩个函数,row-class-name、cell-class-name

这里以cell-class-name单元格样式为例
row-class-name行的 className 的回调方法,也可以使用字符串为所有行设置一个固定的 className。Function({row, rowIndex})/Stringcell-class-name单元格的 className 的回调方法,也可以使用字符串为所有单元格设置一个固定的 className。Function({row, column, rowIndex, columnIndex})/String

  1. <el-table
  2. ref="filterTable"
  3. :data="applyData"
  4. :cell-class-name="tableCellClassName"
  5. style="width: 100%"
  6. stripe
  7. :span-method="objectSpanMethod"
  8. :header-cell-style="{ 'text-align': 'center','background':'#5596F2','color':'#ffffff' }"
  9. :row-style="{'padding':'5px 0px', 'height': '80px'}"
  10. @selection-change="handleSelectionChange"
  11. >
  12. <el-table-column type="selection" fixed width="50" />
  13. <el-table-column prop="wdmc" label="测1" width="300" />
  14. <el-table-column prop="status" label="测2" width="110" />
  15. <el-table-column label="测3" width="935" style="text-align:left">
  16. <template slot-scope="scope">
  17. <el-steps :active="scope.row.active" space="350px" finish-status="success" process-status="process">
  18. <el-step v-for="item,i in scope.row.SubNode" :key="i" :title="`${item.TaskDesc}:${item.User}`" :status="item.processStatus">
  19. <template slot="description">
  20. <!-- <span v-if="item.TaskDesc != '申请人提交' && item.TaskDesc != '审批通过'">审批意见:{{ item.opinion }}</span><br> -->
  21. <span>{{ item.Time }}</span>
  22. </template>
  23. </el-step>
  24. </el-steps>
  25. </template>
  26. </el-table-column>
  27. </el-table>
  1. // 修改样式
  2. tableCellClassName(cel) {
  3. // 行中数据满足某个条件时class设置为bordertop
  4. if (cel.row.isBorder) {
  5. return 'bordertop'
  6. } else {
  7. return 'zcbordertop'
  8. }
  9. }
  1. ::v-deep .bordertop{
  2. border-top: 2px solid #409EFF;
  3. text-align: center;
  4. padding: 7px 0px;
  5. }
  6. ::v-deep .zcbordertop{
  7. text-align: center;
  8. padding: 7px 0px;
  9. }

本文转载自: https://blog.csdn.net/qq_58559853/article/details/130987914
版权归原作者 GoldRoot 所有, 如有侵权,请联系我们删除。

“【前端vue+elemenui】el-table根据表格数据设置整行样式或单元格样式”的评论:

还没有评论