首页 > 解决方案 > 来自未显示在 FullCalendar 4 中的实际日历中的数组的事件

问题描述

我尝试在 FullCalendar 生成的日历中模拟事件。

目前我只是从静态对象(一个可解析对象数组)中获取数据,以便初始化日历中的事件。

在我从我的本地存储中为这个 PoC 获取它之后。

var calendar = new FullCalendar.Calendar(calendarEl, {
        timezone: 'UTC',
        events: [
          {title: "Repos de cycle", start: "2019-11-07T07:00:00.000Z", end: "2019-11-07T11:00:00.000Z"},
          {title: "Repos de cycle", start: '2019-11-07T07:00:00.000Z', end: '2019-11-07T11:00:00.000Z'}
        ],
...

当我调用 eventRender 时,我实际上看到了从日历的“事件”属性中解析的事件对象

        eventRender(info) {
          console.log('rendered event : ', info.event)
        },

在 web 开发者工具中,我实际上得到了我的两个 Event 对象

rendered event :  e {_calendar: e, _def: {…}, _instance: {…}}

rendered event :  e {_calendar: e, _def: {…}, _instance: {…}}

但是日历中没有显示任何内容。

我做错了什么?我应该强制重新渲染还是什么?因为无论发生什么,当我完成配置时,我已经渲染了我的日历。

这是当前情况的codepen:https ://codepen.io/nurovek/pen/zYYWGyX

标签: fullcalendarfullcalendar-schedulerfullcalendar-4

解决方案


当您使用资源时,您需要resourceId为事件定义。所以你应该这样设置。

events: [
   {resourceId: '2', title: "Repos de cycle", start: "2019-11-07T07:00:00.000Z", end: "2019-11-07T11:00:00.000Z"},
   {resourceId: '4', title: "Repos de cycle", start: '2019-11-07T07:00:00.000Z', end: '2019-11-07T11:00:00.000Z'}
],

这是更新的演示https://codepen.io/nasser-ali-karimi/pen/abbPyJj


推荐阅读