【发布时间】:2021-12-18 03:03:12
【问题描述】:
我一直在尝试在 Nextjs 中使用动态导入来使用 screenfull 库,但没有成功。
import dynamic from "next/dynamic"
import screenfull from 'screenfull';
const Screenfull = dynamic(()=>{return import("screenfull")},{})
【问题讨论】:
-
next/dynamic用于动态导入 React 组件。要导入常规 JavaScript 库,您可以简单地使用动态import。有关示例,请参见 Why am I getting ReferenceError: self is not defined in Next.js when I try to import a client-side library?。
标签: javascript reactjs next.js fullscreen