是否可以使用 googleCalendarId 添加事件源?

is it possible to addEventSource using googleCalendarId?

在 "FullCalendar" 中,我可以使用 "addEventSource" 按数组手动添加事件,但是,我无法成功通过 Google 日历 ID 添加事件。

$('#calendar').fullCalendar("addEventSource",{
    events:  [
      {
        title  : 'event1',
        start  : '2019-02-01'
      }
    ]
  });

下面的片段没有通过。请协助

  $('#calendar').fullCalendar("addEventSource",{
    events:  {
      googleCalendarId: 'abcd1234@group.calendar.google.com',
    }
  });

FUllcalendar 仅供参考:来源可能是 Array/URL/Function,就像在事件选项中一样。事件将立即从该来源获取并放置在日历上。

首先请确保您事先已按照文档 (https://fullcalendar.io/docs/google-calendar) 中的所有步骤进行操作,否则将无法正常工作。

其次,你的对象结构是错误的。 events 包装器在指定事件源时不应存在。也许您将 fullCalendar 中的 events 选项混淆为事件源对象所需结构的一部分,记录在此处:https://fullcalendar.io/docs/event-source-object

具体来说,它记录了 google 日历作为源的结构:

{
  googleCalendarId: 'abcd1234@group.calendar.google.com',
  color: 'yellow',   // an option!
  textColor: 'black' // an option!
}

所以我建议您按如下方式更改代码,以匹配记录的对象结构。基本上你只是删除错误的 events 位:

$('#calendar').fullCalendar("addEventSource", {
  googleCalendarId: 'abcd1234@group.calendar.google.com',
});