簡體   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