Fullcalendar年度视图(12月未显示)

问题描述 投票:1回答:1

我需要在fullcalendar中创建一年中所有月份的视图。我发现这个很好的例子除了DECEMBER之外没有出现。

https://codepen.io/webrexRavi/pen/yqMqGX

我不明白代码中有什么问题:

views: {
   timelineCustom: {
       type: 'timeline',
       buttonText: 'Year',
       dateIncrement: { years: 1 },
       slotDuration: { months: 1 },
       visibleRange: function (currentDate) {
           return {
             start: currentDate.clone().startOf('year'),
             end: currentDate.clone().endOf("year")
           };
        }
       }
  }
fullcalendar fullcalendar-scheduler
1个回答
3
投票

好吧,假设当前日期从零开始计数,可见范围预期为1-12个月,currentDate.clone().endOf("year")将显示到11月(12月是从零开始计算的第11个月)。

如果你改成它

currentDate.clone().endOf("year") +1;

它也显示了十二月。

编辑:关于visibleRange的fullcalendar文档says following

visibleRange对象必须具有解析为Moment值的开始/结束属性。结束时刻是独家的,就像API中的所有其他地方一样。

因此,如果您希望范围包含最后一天,则必须添加一天。

currentDate.clone().endOf("year").add(1,'day');
© www.soinside.com 2019 - 2024. All rights reserved.