【问题标题】:Fullcalendar timeGridWeek and timeGridDay not loading correctlyFullcalendar timeGridWeek 和 timeGridDay 未正确加载
【发布时间】:2020-06-02 05:22:10
【问题描述】:

对于我的日历,我正在尝试使用 timeGridWeek 和 timeGridDay 视图。而不是像这样正确加载:

加载如下:

我的日历默认视图是 dayGridMonth,它工作正常。当我单击将视图更改为周或日的按钮时,它无法正确呈现并且也不允许我通过单击按钮进一步更改视图(基本上我被困在我选择的视图中)。

这是我的日历元素 + 导入代码:

import timeGridPlugin from "@fullcalendar/timegrid";
import FullCalendar from "@fullcalendar/react";
import dayGridPlugin from "@fullcalendar/daygrid";
import interactionPlugin, { Draggable } from "@fullcalendar/interaction";

          <FullCalendar
            ref={this.calendarRef}
            defaultView="dayGridMonth"
            height={"parent"}
            width={"parent"}
            droppable={true}
            drop={this.handleDrop}
            dateClick={this.handleDateClick}
            eventClick={this.handleEventClick}
            header={{
              left: "prev,next, today",
              center: "title",
              right: "dayGridMonth,timeGridWeek,timeGridDay"
            }}
            plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]}
            editable={true}
            events={this.state.events}
            eventLimit={true}
          />

提前致谢:)

【问题讨论】:

  • 您的控制台有错误吗?如果我不得不猜测您要么忘记安装插件文件,和/或忘记为更多 CSS 文件添加一个,和/或插件以错误的顺序加载(我不确定import 语句很重要,但我建议先加载核心 fullCalendar 插件,然后是 dayGrid,然后是 timeGrid,然后是 react 插件。交互的位置似乎并不重要)。
  • @ADyson 当我单击星期或日期时,控制台日志如下:main.esm.js:1247 Uncaught TypeError: timeGrid.receiveContext is not a function at SimpleTimeGrid.render (main.esm.js:1247) at SimpleTimeGrid.Component.receiveProps (main.esm.js:3951) at TimeGridView.render (main.esm.js:1331) 还有很多其他内容。看到这个后,我尝试使用 npm 重新安装 timeGrid 插件,但问题仍然存在。

标签: reactjs fullcalendar fullcalendar-4


【解决方案1】:

没关系,它已经修复了!它似乎只是在本地渲染不稳定。当我在 heroku 上托管应用程序时,timeGridWeek 和 day 都呈现得很好。似乎只是安装错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-07
    • 1970-01-01
    • 2023-03-11
    • 2021-05-25
    • 2019-11-01
    相关资源
    最近更新 更多