【问题标题】:Uncaught TypeError: Cannot read property 'top' of null in fullCalendar未捕获的类型错误:无法在 fullCalendar 中读取 null 的属性“顶部”
【发布时间】:2018-05-16 09:45:55
【问题描述】:

对于fullCalendar,我编写了以下代码:

$('#mycalendar').fullCalendar(
            {
                allDaySlot:false,
                slotDuration: '00:30:00' ,  
                //slotMinutes: '120',           
                lang: currentLangCode,
                minTime: '4:00am',
                maxTime: '24:00pm',
                slotEventOverlap: true,
                slotLabelFormat:'h(:mm)a',
                showAgendaButton: true,
                columnFormat: { month: 'ddd', week: 'ddd M/D', day: 'ddd M/D' },
                timeFormat: 'H:mm',
                defaultView: 'listWeek',
                eventLimit: true,
                theme:false,
                editable: true,
                contentHeight:'auto',
                weekends: false ,
                //timezoneParam: 'America/Los_Angeles',
                //ignoreTimezone: false,
                header:
                {
                    left: 'prev,next today',
                    center: 'title',
                    // right: 'agendaWeek'
                    right: 'month,agendaWeek,agendaDay,listWeek'
                },
                views: {
                    listDay: { buttonText: 'Day' },
                    listWeek: { buttonText: 'Week' },
                    month: {
                        columnFormat: 'ddd'
                    },
                    agenda: {
                        columnFormat: 'ddd'
                    }
                },

我的议程周和议程日出现以下错误:

我正在使用:

jQuery JavaScript 库 v3.3.1 FullCalendar v3.9.0

【问题讨论】:

    标签: javascript fullcalendar momentjs fullcalendar-3


    【解决方案1】:

    这是因为您的 minTimemaxTime 值无效且不可解析为 momentJS 对象。 fullCalendar 依靠 momentJS 进行日期和时间处理。因此,日历不知道从哪里开始显示(因此日历的“顶部”在哪里,因此出现错误消息)。

    将它们设置为

    minTime: '04:00',
    maxTime: '24:00',
    

    改为。

    查看这里的工作演示:http://jsfiddle.net/sbxpv25p/581/

    请参阅http://momentjs.com/docs/#/parsing/string/ 以获取 momentJS 可以识别的有效日期/时间格式列表。您会看到“am”和“pm”不是可识别的项目。无论如何,它们也是不必要的,因为您已经指定了 24 小时格式的时间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-18
      • 2013-12-09
      • 2016-05-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多