html部分:
<el-table-column
prop="phoneCache"
label="手機緩存包編號"
align="center"
:sortable="true"
:sort-method="sortByVesselName"
width="140">
</el-table-column>
js部分:
sortByVesselName(obj1, obj2) {
let num1 = obj1.phoneCache.substring(2);
let num2 = obj2.phoneCache.substring(2);
return num1-num2;
}
去除掉字符串,使數字進行排序可以在排序方法中自定義自己想要的排序邏輯。