element-ui table表格的排序

首先阅读api文档,文档还是说的很清楚

http://element-cn.eleme.io/#/zh-CN/component/table

本人实践:

向后台服务发请求,进行数据列表的排序,先在需要排序的字段上增加sortable="custom" 和prop,比如使用开始使用排序 prop="createTime";

然后在el-table上绑定事件@sort-change="sortChange";

实现业务

//排序

sortChange(column, prop, order) {

     if (column.order === 'descending') {

         this.listQuery.order = 'desc'

     } else {

         this.listQuery.order = 'asc'

    }

   this.listQuery.sort = column.prop

   this.queryList(this.listQuery)

},

猜你喜欢

转载自blog.csdn.net/mobile18611667978/article/details/88689078
今日推荐