【发布时间】:2021-01-12 02:05:04
【问题描述】:
我在我的项目中使用gatsby-image-background-slider,它会触发TypeError: Cannot read property 'style' of undefined changeIndex src/index.js:111 callback src/index.js:129。
最初是同一个英雄,但在开发过程中,它开始出现此错误。我已经重新安装了软件包,尝试使用相同代码的新 hello-world-project。
Hero.js
import React from "react"
import { useStaticQuery, graphql } from "gatsby"
import BackgroundSlider from 'gatsby-image-background-slider'
const Hero = ({ children }) => (
<>
<main>{children}</main>
<BackgroundSlider
query={useStaticQuery(graphql`
query {
backgrounds: allFile (filter: {sourceInstanceName: {eq: "backgrounds"}}){
nodes {
relativePath
childImageSharp {
fluid (maxWidth: 4000, quality: 100){
...GatsbyImageSharpFluid
}
}
}
}
}
`)}
initDelay={2}
transition={4}
duration={8}
images={["picture2.jpg", "picture2.jpg"]}
>
</BackgroundSlider>
</>
)
export default Hero
你知道是什么原因造成的吗?
【问题讨论】:
-
prop的风格在哪里? -
我使用全局 css。