【发布时间】:2021-04-13 10:53:50
【问题描述】:
我试图将阵列图像数组中的对象映射到单独产品页面上的图像库(来自strapi)。出现正确数量的图像,但它在它们上重复相同的图像。即使在不应在其各自数组中包含该图像的产品页面上也是如此。示例 - https://imgur.com/a/PKlpofy
我检查了来源和图像 src 链接都是同一图像的不同版本。 - https://imgur.com/a/968w77b
GraphIQL - https://imgur.com/a/HvgMA8r
任何关于我哪里出错的指针都会很棒!如果您需要更多信息,请告诉我。
代码-
<div className="image-grid">
{data.home.galleryImage.map((image, id, caption) => (
<Image fluid={image.formats.medium.childImageSharp.fluid} alt="hh" key={id} class="galleryimg" thumbnail/>
))
}
</div>
</div>
GraphQL 查询 -
export const query = graphql`
query GetSingleHome($slug: String) {
home: strapiHomes(slug: { eq: $slug }) {
galleryImage {
id
formats {
medium {
childImageSharp {
fluid(maxWidth: 400, maxHeight: 250) {
...GatsbyImageSharpFluid
}
}
}
}
}
}
}
`
【问题讨论】:
标签: javascript reactjs graphql gatsby