【发布时间】: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