如何在Fullcalendar React V5 Scheduler中通过JSON流获取资源?

问题描述

我在全日历调度程序中通过带有响应的json提要提供资源时遇到了问题。该Feed可以在正常的全日历计划程序中正常运行,而无需做出反应。

import React from 'react';
import FullCalendar from '@fullcalendar/react';
import resourceTimelinePlugin from '@fullcalendar/resource-timeline';
import calendarInteraction from '@fullcalendar/interaction';

class Calendar extends React.Component {
    state = {};


    render() {
        return (
            <div>
                <FullCalendar
                    schedulerLicenseKey="GPL-My-Project-Is-Open-Source"
                    plugins={[calendarInteraction,resourceTimelinePlugin]}
                    initialView={'resourceTimelineMonth'}
                    selectable={true}
                    editable={true}
                    resourceAreaWidth={'10%'}
                    resources={"localhost/resources"}
      />
            </div>
        );
    }
}
export default Calendar;

我在控制台中收到以下错误: 警告:无法在尚未安装的组件上调用setState。这是一项禁止操作,但它可能表明您的应用程序中存在错误。而是直接分配给this.state或在CalendarDataProvider组件中使用所需状态定义一个state = {};属性

它看起来像一个反应问题,但我不明白。全日历在哪里响应“插件”保存资源状态?

解决方法

对不起,我找到了答案:

似乎您必须在react fullcalendar中显式地给出一个绝对URL,但是没有react的fullcalendar版本也可以用于非显式URL。

因此resources={"http://localhost/resources"}有效。而且resources={"localhost/resources"}不起作用!

感谢@ADyson给出了答案。