Gatsby I';我很难在盖茨比插件图像上传递道具

Gatsby I';我很难在盖茨比插件图像上传递道具,gatsby,gatsby-image,Gatsby,Gatsby Image,我想从盖茨比映像迁移到盖茨比插件映像。道具有问题 (已从盖茨比插件图像中查询) 查询我的查询{ 商品化( shopifyId:{eq:$shopifyId} ) { 标题 描述 图像{ 本地文件{ childImageSharp{ gatsbyImageData(布局:受约束,占位符:模糊,格式:WEBP) } } } } }您只需: import { GatsbyImage } from "gatsby-plugin-image" const ImageGallery

我想从盖茨比映像迁移到盖茨比插件映像。道具有问题

(已从盖茨比插件图像中查询)


查询我的查询{
商品化(
shopifyId:{eq:$shopifyId}
) {
标题
描述
图像{
本地文件{
childImageSharp{
gatsbyImageData(布局:受约束,占位符:模糊,格式:WEBP)
}
}
}
}
}
您只需:

import { GatsbyImage } from "gatsby-plugin-image"

const ImageGallery = ({ images }) => {
  return (
    <div>
     <GatsbyImage image={images[0].localFile.childImageSharp.gatsbyImageData} alt=""/>
    </div>
  )
}
从“盖茨比插件图像”导入{GatsbyImage}
常量图像库=({images})=>{
返回(
)
}

使用新的
gatsby插件图像
您不再需要调用固定图像或流体图像,信息存储在
gatsbyImageData
中,以前在GraphQL查询中查询和过滤。

有问题/问题和“变得复杂”不是问题描述。运行代码时会发生什么?为什么那么糟糕?该怎么办?谢谢你,费伦!有意义的
.localFile.childImageSharp.gatsbyImageData
。我做得不对。费兰,我能用盖茨比插件图片而不用盖茨比图片做所有与图片相关的事情吗?是的,你可以做完全相同的事情,还有更多谢谢你费兰!