業(yè)務(wù)場(chǎng)景:表格有”發(fā)布時(shí)間“一列弦叶,發(fā)布時(shí)間可以點(diǎn)擊上下箭頭排序(和后臺(tái)交互排序所有數(shù)據(jù)符喝,非當(dāng)前表格里的幾條)招狸。
html:
<el-table :data="tableData" style="width: 100%" @sort-change="sortChange">
<!-- sortable="custom"很重要 -->
<el-table-column prop="publishTime" sortable="custom" label="發(fā)布時(shí)間" > </el-table-column>
</el-table>
js:
sortChange(column) {
//打印可以分別得到上下箭頭的數(shù)據(jù)
console.log(column);
if (column.order == "ascending") {
this.orderBy = "+";//根據(jù)自己的業(yè)務(wù)需求來
} else if (column.order == "descending") {
this.orderBy = "-";
} else {
this.orderBy = "";
}
//有多列排序時(shí)會(huì)用到
// if (column.prop == "publishTime") {
// this.key = "publish_time ";
// } else if (column.prop == "updateTime") {
// this.key = "update_time";
// } else {
// this.key = "";
// }
this.currentPage = 1;
this.searchData();//查詢列表方法
},