1.table上要加 @sort-change="sortChange"
2.需要排序的列加上 sortable="custom" 不然不生效
<el-table :data="dataList" @sort-change='changeSort'>
// 需要排序的列添加 sortable="custom" 后端排序
<el-table-column label="创建时间" prop="createTime" sortable="custom" />
</el-table>
// 排序的方法 每次排序会触发
changeSort(val) {
const order = val.order
if (order === 'ascending') {
this.query.sort = 'id' + ',asc'
} else {
this.query.sort = 'id' + ',desc'
}
this.$nextTick(() => {
// 重新从接口拿数据
this.getOrderList(0, this.pageSize)
})
},