AntDesignTable中日期排序问题

业务效果

业务代码

参考ant design内Table表头日期字段排序

  • moment方法,仅用于处理日期格式
import moment from 'moment'
  • sorter为组件内字段
  {
    title: '计划日期',
    dataIndex: 'parentPlanApprovalDate',
    width: 150,
    defaultSortOrder: 'descend', // 默认上到下为由大到小的顺序
    sorter: (a, b) => {
      return new Date(a.parentPlanApprovalDate) > new Date(b.parentPlanApprovalDate) ? 1 : -1;
    },
    customRender: function (text){
      if(text == '' || text == null){
        return '/';
      } else {
        return moment(text).format("YYYY-MM-DD");
      }
    }
  },

posted @ 2023-03-06 14:30  Felix_Openmind  阅读(635)  评论(0)    收藏  举报
*{cursor: url(https://files-cdn.cnblogs.com/files/morango/fish-cursor.ico),auto;}