avue-curd 不同列设置不同的对齐方式

      :cell-class-name="addCellClass"
      :header-cell-class-name="addCellClass"

可以通过指定 组件的 row-class-name 属性来为 crud 中的某一行添加 class,表明该行处于某种状态,返回当前行的row数据和行的序号index;

header-cell-class-name 表头单元格的className的回调方法,也可以使用字符串为所有表头单元格设置一个固定的className

<template>
  <div class="tableCrudBox">
    <avue-crud
      ref="tableCrudDialog"
      class="tableCrud"
      :data="tableData"
      :option="tableOptions"
      :table-loading="showLoading"
      :cell-class-name="addCellClass"
      :header-cell-class-name="addCellClass"
    >
    </avue-crud>
  </div>
</template>

 

    methods: {
      addCellClass({ row, column }) {
        // 'aaa','bbb'为列的 prop
        const leftArr = ['aaa','bbb'], rightArr = ['ccc','ddd'], centerArr = ['eee','fff']
        if (leftArr.includes(column.property)) {
          return 'cell-left'
        } else if (rightArr.includes(column.property)) {
          return 'cell-right'
        } else if (centerArr.includes(column.property)) {
          return 'cell-center'
        }
      }
    }

 

 通过addCellClass()方法为表格的头和行添加了指定的class,接下来为指定类设置样式:

<style lang="scss" scoped>
.tableCrudBox{
  .tableCrud{
    // 表头样式
    /deep/ .el-table th.el-table__cell.is-leaf.cell-left {
      text-align: left;
    }
    /deep/ .el-table th.el-table__cell.is-leaf.cell-right {
      text-align: right;
    }
    /deep/ .el-table th.el-table__cell.is-leaf.cell-center {
      text-align: center;
    }
    // 表格行样式
    /deep/ .el-table td.el-table__cell.cell-left {
      text-align: left;
    }
    /deep/ .el-table td.el-table__cell.cell-right {
      text-align: right;
    }
    /deep/ .el-table td.el-table__cell.cell-center {
      text-align: center;
    }
  }
}

</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值