繁体   English   中英

setOption startParam 在 fullcalendar v5 中的工作很奇怪

[英]setOption startParam works weird in fullcalendar v5

我试图动态设置startParam选项。

但是通过更新键而不是更新值似乎很奇怪。

calendarEvents.setOption('startParam', moment().format());
calendarEvents.refetchEvents();

如果我运行这些方法并检查表单数据,那么startParam将如下所示。

2021-02-15T19:09:13-07:00: 2021-01-01T00:00:00-07:00
end: 2030-01-01T00:00:00-07:00

我猜setOption方法会更新开始参数的键而不是值。

为什么会发生这种情况以及如何解决这个问题?

更新:我的日历代码

calendarEvents = new FullCalendar.Calendar(calendarEventsEl, {
        headerToolbar: false,
        contentHeight: 300,
        initialView: 'listAll',
        views: {
            listAll: {
                type: 'listYear',
                duration: { years: 9 },
            },
        },
        navLinks: false,
        eventDidMount: function (arg) {
            ...
        },
        eventTimeFormat: {
            hour: 'numeric',
            minute: '2-digit',
            meridiem: 'short'
        },
        eventSources: [{
            method: 'POST',
            url: '/calendar/get_all_by_id/' + id,
        }],
        eventSourceSuccess: function(content, xhr) {
            ...

            return events;
        }
    });

    calendarEvents.render();
})

它工作正常。

startParam 选项设置参数的名称,fullCalendar 在获取事件时发送给服务器以获得起始值。 它没有设置值。 发送的值始终是用户刚刚导航到的范围的开始日期。 您不需要自己更改该值,无论如何尝试给它一个固定值是没有意义的 - 每次需要获取事件时,它都会由 fullCalendar 动态调整。

你实际上想用这段代码实现什么? 您是否尝试以编程方式更改日历上的当前日期? 如果是这样,那么使用https://fullcalendar.io/docs/Calendar-gotoDate

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM