1.在 table表单中添加sort-change事件, :sort-orders="['ascending', 'descending']"
<el-table :data.sync="tableData" border height="520" size="small" class="table"
ref="multipleTable"
style="width:100%"
:row-key="getRowKeys"
@sort-change="getSortChange"
:sort-orders="['ascending', 'descending']"
@selection-change="handleSelectionChange">
<el-table-column type="selection" :reserve-selection="true" width="55"></el-table-column>
<el-table-column prop="code" label="编号" v-if="show_code" sortable :sort-orders="['ascending', 'descending']"></el-table-column>
<el-table-column prop="title" label="广告名称" v-if="show_title"></el-table-column>
</el-table>
2.js
//排序
getSortChange(column){
if (column.order === 'descending') {
this.orderByColumn = column.prop;
this.isAsc = 'desc'
} else {
this.orderByColumn = column.prop;
this.isAsc = 'asc'
}
this.list()
},
网友评论