0

自定义按钮和自定义视图不起作用。这是一个代码:

var calendar = new FullCalendar.Calendar(document.getElementById('calendar'), {
    headerToolbar: {
        left: 'today,newEvent,dayGridYear,monthNew',
        center: 'title',
        right: 'prevYear,prev,next,nextYear',
    },
    customButtons: {
        myCustomButton: {
            text: 'custom!',
            click: function() {
                alert('clicked the custom button!');
            }
        }
    },
    navLinks: true,
    views: {
        monthNew: {
            type: 'month',
            duration: {months: 3},
            defaults: {fixedWeekCount: false},
            buttonText: '4 day'
        },
        dayGridYear: {
            type: 'timeline',
            buttonText: 'Year',
            dateIncrement: { years: 1 },
            slotDuration: { months: 1 },
            visibleRange: function (currentDate) {
                return {
                    start: currentDate.clone().startOf('year'),
                    end: currentDate.clone().endOf("year")
                };
            }
        }
    }
});
calendar.render();

在标题工具栏中,我只看到空文本按钮,单击不做任何事情。

全日历版本:5.3.2

4

1 回答 1

0

配置中有几个问题:

  1. “月”不是有效的视图类型。dayGrid是显示该类型网格的基本视图类型。使用type: 'dayGrid'将解决此问题。

  2. 您尚未定义名为“newEvent”的自定义视图或按钮,因此它永远不会在标题中正确显示。目前尚不清楚此设置的目的是什么。

  3. 您已经定义了一个名为“myCustomButton”的自定义按钮,但您没有在标题中为其添加条目,因此它永远不会出现。

  4. 时间线视图需要调度程序高级插件。因此,除非您包含 Scheduler JS 和 CSS 文件(并确保您拥有适合您的场景的许可证),否则这将不起作用。

于 2020-10-07T14:19:03.870 回答