想实现以下结果:
带小数点排序问题
只需在表头上加上一个sortable属性即可
注意1、当数据中出现小数,导致排序错乱
解决方法:需要在el-table-column中添加:sort-method="(a,b)=>{return a.construction_scale - b.construction_scale}"
<el-table-column
prop="construction_scale"
label="建设规模"
width="120"
:sortable="true"
:sort-method="(a, b) => { return a.construction_scale - b.construction_scale; }"
>
</el-table-column>
注意2、当数据需要使用%来显示,直接返回的数据含有%导致排序错乱,需要返回正常数字,在这里进行拼接%
解决方法: 拼接数字{{scope.row.price}}%
<el-table-column
prop="price"
label="价格"
width="200"
sortable
:sort-method="(a,b)=>{return a.price - b.price}">
<template slot-scope="scope">
{{scope.row.price}}%
</template>
</el-table-column>