我正在尝试按时间段(例如00:30、01:00、01:30等)对事件进行分组,以将其显示在日历中。
但是,当遍历插槽并过滤事件时,每次每个事件在22:00都输出错了吗?我似乎看不到这个问题。
也许与Moment可变有关吗?
Here is my CodeSandbox example for full code.
Cut
事件数据:
const slots = getSlots();
let array = {};
slots.map((slot, index) => {
const eventsInSlot = filter(events, event => {
const time = moment(event.time);
const start = moment(slot, "HH:mm");
const end = moment(slots[index - 1], "HH:mm");
return time.isBetween(end, start, "minutes", "[]");
});
if (eventsInSlot.length !== 0) {
array[slot] = eventsInSlot;
}
});
console.log(array);