前端全部数据排序
加上@sort-change=“sort_change”,sortable=“custom”
<!--列表-->
<el-table
size="small"
:data="currData"
highlight-current-row
v-loading="loading"
border
element-loading-spinner="el-icon-loading"
style="width: 100%"
@sort-change="sort_change"
>
<el-table-column type="index" label="序号" width="150"> </el-table-column>
<el-table-column prop="name" label="类型" width="150"> </el-table-column>
<el-table-column prop="componentTotal" label="组件总数" sortable="custom">
</el-table-column>
<el-table-column prop="versionTotal" sortable="custom" label="版本总数">
</el-table-column>
<el-table-column
sortable="custom"
prop="dependencyTotal"
label="依赖总数"
>
</el-table-column>
<el-table-column
sortable="custom"
prop="yesterdayComponent"
label="昨日组件增量"
>
</el-table-column>
<el-table-column
sortable="custom"
prop="yesterdayVersion"
label="昨日版本增量"
>
</el-table-column>
<el-table-column sortable prop="yesterdayDependency" label="昨日依赖增量">
</el-table-column>
</el-table>
sort_change函数
// 全部数据排序
sort_change(column) {
// column是个形参,具体查看element-ui文档
let { order, prop } = column;
// 判断排序方式
if (order == "descending") {
this.listData = this.listData.sort((a, b) => {
return b[prop] - a[prop];
});
} else {
this.listData = this.listData.sort((a, b) => {
return a[prop] - b[prop];
});
}
this.currentPage = 1;
this.total = this.listData.length;
console.log(123, this.listData);
this.currData = this.listData.slice(0, this.pageSize);
},