elementui 前端自定义排序

123 阅读1分钟

按照姓名首字母排序

      <el-table-column
        prop="doctorName"
        minWidth="350"
        align="center"
        sortable
        label="客户"
        :sort-method="sortName"
        :disabled-show="true"
      >
          sortName(a, b) {
      return a.doctorName.localeCompare(b.doctorName)
    },

按照日期排序

      <el-table-column
        v-if="checkedCities.includes('上次拜访时间')"
        prop="lastVisitTime"
        align="center"
        sortable
        :sort-method="
          (a, b) => {
            return new Date(a.lastVisitTime) - new Date(b.lastVisitTime)
          }
        "
        label="上次拜访时间"
        minWidth="180"
      >