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

moment方法,仅用于处理日期格式

import moment from 'moment'

sorter为组件内字段


        {
          title: '截止日期',
          width: 150,
          align: "center",
          dataIndex: 'endTime',
          sorter: (a, b) => {
            return new Date(a.endTime) > new Date(b.endTime) ? 1 : -1;
          },
          customRender: function (text){
            if(text == '' || text == null){
              return '/';
            } else {
              return moment(text).format("YYYY-MM-DD");
            }
          }
        },

相关文章: