小编Dan*_*dze的帖子

fullcalendar - NextJS - 动态导入不显示日历

我正在使用 NextJS 和 Fullcalendar。

我尝试fullcalendar这个例子中使用动态导入(有关更多信息,这个示例解决方案来自这里)。

它奏效了,但有一个问题。几乎每 5 次刷新尝试中就有 1 次以错误告终Please import the top-level fullcalendar lib before attempting to import a plugin就像这样,但在我的情况下版本是正确的)

之后,我发现 next/dynamic 的模块选项已被弃用。我认为这是我的问题的根源(我不确定 100%,但至少它已被弃用并需要更新)。

正如文档所说,处理动态导入的新方法是这样的:

const DynamicComponent = dynamic(() =>
  import('../components/hello').then((mod) => mod.Hello)
)
Run Code Online (Sandbox Code Playgroud)

但是因为我们需要多次导入,所以我找到了这个解决方案

目前,似乎一切正常,但我的代码无效。

import dynamic from "next/dynamic";
import { useEffect, useState } from "react";

import "@fullcalendar/common/main.css"; // @fullcalendar/react imports @fullcalendar/common
import "@fullcalendar/daygrid/main.css"; // @fullcalendar/timegrid imports @fullcalendar/daygrid
import "@fullcalendar/timegrid/main.css"; // @fullcalendar/timegrid is a …
Run Code Online (Sandbox Code Playgroud)

fullcalendar reactjs next.js react-loadable fullcalendar-5

8
推荐指数
2
解决办法
1182
查看次数