【问题标题】:Calendar iframe doesn't show all latest created events(especially shared calendar events)日历 iframe 不显示所有最新创建的事件(尤其是共享日历事件)
【发布时间】:2023-03-22 02:15:01
【问题描述】:

我已经设法将 Google 日历嵌入到 React 组件中,但问题是我可以观察到嵌入的日历没有获取添加到使用 gapi 进行身份验证的电子邮件中的最新事件。

日历 iframe 网址是 https://calendar.google.com/calendar/b/1/embed?src={VALID_CALENDAR_EMAIL}

calendar.util.js

const CALENDAR_EMBED_BASE_URL =
  'https://calendar.google.com/calendar/embed?src=';

export const getCalendarEmbedUrl = email =>
  `${CALENDAR_EMBED_BASE_URL}${email}`;

CalendarIframe.jsx 组件

import React, { PureComponent } from 'react';
import { getCalendarEmbedUrl } from 'calendar.util.js';

class CalendarIframe extends PureComponent {
  render() {
    const { email } = this.props;
    const embedUrl = getCalendarEmbedUrl(email);

    return (
      <div className="calendarEmbedWrapper">
        <iframe
          title="Calendar"
          id="calendarEmbed"
          width="100%"
          src={embedUrl}
        />
      </div>
    );
  }
}

有什么方法可以确保嵌入式日历具有应有的动态性?

【问题讨论】:

    标签: javascript reactjs iframe google-calendar-api google-api-js-client


    【解决方案1】:

    我想出了如何解决嵌入式日历问题。在嵌入字符串中,我只需将所有 calendarId 附加到字符串中,如下所示: https://calendar.google.com/calendar/embed?src=calendarID + &amp;src=anotherCalendarId

    https://calendar.google.com/calendar/embed?src=email@email.com&amp;src=anothercalendar@group.calendar.google.com

    它将显示来自嵌入的多个日历 ID 的所有事件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-06
      • 2012-01-15
      • 1970-01-01
      • 2015-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多