Fullcalendar 年视图(未显示 12 月)

Fullcalendar Year view (December not showed)

我需要在全日历中创建一年中所有月份的视图。 我发现这个很好的例子,除了 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")
           };
        }
       }
  }

好吧,假设 currentDate 从零开始计算月份,并且可见范围期望月份的值介于 1-12 之间,然后 currentDate.clone().endOf("year") 将显示到 11 月(从零开始计算时,12 月是第 11 个月) .

如果你把它改成

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

它也显示十二月。

编辑: 关于 visibleRange 的完整日历文档 says following

The visibleRange object must have start/end properties that resolve to Moment values. The end moment is exclusive, just like all other places in the API.

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

currentDate.clone().endOf("year").add(1,'day');