格式是“08:00-09:00”,先用split('-')分割判断前一个时间大小,前一个大小一样再判断后一个时间的大小
sorter: (a, b) => {
let aTime = a.hours;
let bTime = b.hours;
let aStart = aTime.split('-')[0]
let aEnd = aTime.split('-')[1]
let bStart = bTime.split('-')[0]
let bEnd = bTime.split('-')[1]
if(aStart==bStart){
if(aEnd=='00:00'){
aEnd='24:00'
}
if(bEnd=='00:00'){
bEnd='24:00'
}
return moment.duration(aEnd).as('second')*1000 - moment.duration(bEnd).as('second')*1000//转换成毫秒比较大小
}else{
return moment.duration(aStart).as('second')*1000 - moment.duration(bStart).as('second')*1000
}
},