1

我正在使用 Fullcalendar V5。尝试在 resourceTimelineWeek 视图中将滚动时间设置为当前日期和时间时,仅时间工作正常,但我该如何设置日期滚动。

var scrollTime = moment().format("HH") + ":00:00"; 
    
 document.addEventListener('DOMContentLoaded', function() {
  var calendarEl = document.getElementById('calendar');
    var calendar = new FullCalendar.Calendar(calendarEl, {
now: new Date(),
scrollTime: scrollTime
}
)};

现在是 09:30,时间显示正确。但是日期是 10 月 1 日,在日历滚动视图上仍然是 9 月 27 日。 只工作时间

4

1 回答 1

0

在 FullCalendar 5.8.0 上测试(使用 jQuery 和 moment.js)

options = {
    datesSet: ({ view }) => {
        if (view.type === 'resourceTimelineWeek') {
            const scroller = $('.fc-scrollgrid-section-body .fc-scroller').last();
            const [date] = moment().toISOString().split(':');
            const position = $(`.fc-timeline-slot[data-date^="${date}"]`).last().position();
            if (position) {
                scroller.scrollLeft(position.left);
            }
        }
    }
}
于 2021-06-25T13:59:49.177 回答