接在排序表头中留下的坑
使用js对list进行排序
this.showDataList.sort((a, b) => a.viewNum - b.viewNum); //升序
使用
es5写法
this.showDataList = this.showDataList.sort(
function(a, b) {
return a.viewNum - b.viewNum;
}
);
clickOrder2: function() {
this.orderIcon2 = -this.orderIcon2;
this.showDataList =
this.showDataList.sort((a, b) => this.orderIcon2 * (a.viewNum - b.viewNum)); //升序
},
clickOrder3: function() {
this.orderIcon2 = '-1';
this.orderIcon3 = '';
this.showDataList =
this.showDataList.sort((a, b) => (b.viewNum - a.viewNum));
//降序
},
网友评论