Ant Design of Vue表格排序以及自定义样式

文章详细描述了如何在表格组件中实现区域路径名的自定义样式,包括背景颜色和行间切换,以及根据时间或数字进行排序的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.自定义样式

{
          title: '区域',
          dataIndex: 'pathName',
          key: 'pathName',
            //控制单列样式
          customCell: (record, rowIndex) => {
            return {
              style: {
                'background-color': '#063d79'
              },
              class: ['boxColor' + (rowIndex % 2), 'one']
            }
          },
            //排序
    sorter: (a, b) => {
            let aTime = a.startTime ? new Date(a.startTime).getTime() : 0 // 需要先转换成时间戳
            let bTime = b.startTime ? new Date(b.startTime).getTime() : 0
            return aTime - bTime
          },
          width: this.$global.tableTitleWidth.pathname,//宽度
            //自定义内容以及单个点击事件
          customRender: (text, record, index) => {
            if (text) {
              if (text) {
                let pathNames = text.split('/')[1] + (text.split('/')[2] ? '/' + text.split('/')[2] : '')
                return (
                  <div class="ellipsisText"  onClick={(e) => this.onbasicinformation(record)}>
                    <a-tooltip placement="topLeft" overlayClassName="ellipsisTexttooltip">
                      <template slot="title">
                        <span style="color:#000;font-size: 18px;">{pathNames}</span>
                      </template>
                      {pathNames}
                    </a-tooltip>
                  </div>
                )
              } else {
                return '-'
              }
            }
          },
        },

2.排序

根据时间排序

sorter: (a, b) => {
            let aTime = a.startTime ? new Date(a.startTime).getTime() : 0 // 需要先转换成时间戳
            let bTime = b.startTime ? new Date(b.startTime).getTime() : 0
            return aTime - bTime
          },

根据数字排序

 sorter: (a, b) => a.Datas - b.Datas,

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值