sort-change当表格的排序条件发生变化的时候会触发该事件:
调试发现方法已执行,但是最终排序未生效到表格。因为表格排序只执行一次,需要禁掉默认排序。
<el-table
class="table"
ref="table"
:data="list"
:default-sort="{prop: 'SlideNo', order:'ascending'}"
@sort-change="sortChange"
>
</el-table>
自定义排序 :
sortChange(column, prop, order) {
//需要先清除默认排序 !!!
if (this.$refs.table) this.$refs.table.clearSort()
// sort...
}
~~~ 测试通过,已按自定义排序 ~~~