文章目錄
-
-
- 排序
- 排序最大值加1
- _.maxBy
- _.groupby用法
- 排序 使用 案例
-
排序
根據對象的某個字段降序
return _.orderBy(
this.subDistrictIndexes.map(v => {
return {
name: v.district.name,
value: v.index == null ? 0 : v.index.aqi,
grade: v.index == null ? null : v.index.aqiGrade
};
}),
"value",
"desc"
);
排序最大值加1
_.maxBy
在數組對象裡面根據某個屬性的最大值傳回那個對象
_.groupby用法
排序 使用 案例
get orderedPatrolEventOverviews() {
let eventList = orderBy(
this.patrolEventOverviews.filter(e => {
return this.eventPredicate(e);
}),
[
p => p.year,
p => p.month,
p => p.dayOfMonth,
p => p.hour,
p => p.minute
],
["desc", "desc", "desc", "desc", "desc"]
);
this.total = eventList.length;
return this.pageList(eventList);
}