在列中设置sortable属性即可实现以该列为基准的排序,接受一个Boolean,默认为false。可以通过 Table 的default-sort属性设置默认的排序列和排序顺序。
在列中使用sort-by定义排序规则
在第一个参数相等的情况下,对第二个参数
代码如下:
<template>
<div class="about">
<h1>About Element UI Table</h1>
<el-table
:data="tableData"
style="width: 100%"
:default-sort="{prop: 'fee',order:'descending'}">
<el-table-column type="index">
<template slot-scope="scope">
<div :class="scope.$index<=2?'highlight-index':''">{
{
scope.$index+1}}</div>
</template>
</el-table-column>
<el-table-column
prop