1.在methods中写排序方法
sort(type) { this.List = this.List.sort(this.compare(type));},// 排序公共方法compare(property){ return function(a,b){ let value1 = a[property]; let value2 = b[property]; return value2 - value1; }},
2.点击事件中调用
@click="sort('type')"