<el-table-column
v-for="(item, index) in tableHeader"
:key="index"
:prop="item.props"
:label="item.label" sortable
:sort-method="(a, b) => {return a[item.props] - b[item.props]}">
</el-table-column>
因为数据格式问题,table组件自带的排序可能会不准确,是错误的,所以用
:sort-method="(a, b) => {return a[item.props] - b[item.props]}"
这句代码
就可以解决排序不正确的问题了
因为我们的需求列表是每列都需要排序,所以使用了for循环,循环了每一列的数据,表头也是后端自定义返回的
大家要是有更好的写法,也欢迎指出哦~互相学习