changeTableSort_1(column) { //名称排序
var sortingType = column.order;
if(sortingType == "descending"){
this.list = this.list.sort((a, b) =>b.courseType.title.localeCompare(a.courseType.title));
}
else{
this.list = this.list.sort((a, b) => a.courseType.title.localeCompare(b.courseType.title));
}
console.log(this.list);
},
<el-table
height="620"
border
ref="filterTable"
:data="list"
highlight-current-row
:style="contentStyleObj"
@sort-change="changeTableSort_1"
:default-sort = "{order: 'descending'}"
:header-cell-style="tableHeaderColor"
>
<el-table-column
align="center"
label="分类"
:sortable="'custom'"
>
<template slot-scope="scope">
<div v-if="scope.row.courseType !=null">
{{scope.row.courseType.title}}
</div>
</template>
vue+Element-ui table按照字母排序
最新推荐文章于 2024-05-28 15:21:57 发布