【发布时间】:2021-07-30 08:37:24
【问题描述】:
我正在尝试使 gatsby-background-image 与 v3 的 gatsby-plugin-image 一起使用。我遵循了文档,发现我应该使用 gbimage-bridge。
由于某种原因,它似乎不起作用。在 ide 中测试时,我的查询工作正常。我试图以各种方式更改我的查询和常量,但似乎无法使其工作。
现在它只输出文本 Test 但没有显示背景。
我的代码:
import { graphql, useStaticQuery } from "gatsby"
import { getImage } from "gatsby-plugin-image"
import { BgImage } from "gbimage-bridge"
const GbiBridged = () => {
const { backgroundImage123 } = useStaticQuery(graphql`
query {
backgroundImage123: allWpPage {
nodes {
ACFforside {
heroimg {
localFile {
childImageSharp {
gatsbyImageData(
width: 2000
quality: 50
placeholder: BLURRED
formats: [AUTO, WEBP, AVIF]
)
}
}
}
}
}
}
}
`)
const pluginImage = getImage(backgroundImage123)
return (
<BgImage image={pluginImage}>Test</BgImage>
)
}
export default GbiBridged
【问题讨论】:
标签: javascript reactjs graphql gatsby gatsby-image