【问题标题】:Events from an array not showing in the actual calendar in FullCalendar 4来自未显示在 FullCalendar 4 中的实际日历中的数组事件
【发布时间】:2019-11-15 14:47:23
【问题描述】:

我尝试在 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

【问题讨论】:

    标签: fullcalendar fullcalendar-scheduler fullcalendar-4


    【解决方案1】:

    当您使用资源时,您需要为事件定义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'}
    ],
    

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

    【讨论】:

    • 天哪,是的!当然必须给资源...非常感谢!
    猜你喜欢
    • 2020-02-25
    • 1970-01-01
    • 1970-01-01
    • 2020-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-04
    相关资源
    最近更新 更多