【发布时间】:2021-11-23 23:46:52
【问题描述】:
有谁知道如何用 react-spring-3d-carousel 解决这个问题 Gatsby:
从“react-spring-3d-carousel”导入轮播
和
<Carousel slides={slides} goToSlide={selectedSlide} />.
我查看了文档,但仍然出现错误:未定义窗口
gatsby-node.js
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === "build-html") {
actions.setWebpackConfig({
module: {
rules: [
{
test: /react-spring-3d-carousel/,
use: loaders.null(),
},
],
},
})
}
}
任何帮助将不胜感激
【问题讨论】:
-
当
windownot defined 出现时?gatsby develop或gatsby build? -
@FerranBuireu gatsby 开发,但我修复了@loadable/component。这两行解决了我的问题。从“@loadable/component”导入可加载; const Carousel = loadable(() => import("react-spring-3d-carousel")) 再次感谢 :)
-
@Josh 谢谢,我刚刚找到我的问题并使用@loadable/component 修复。