Graphql …GatsbySanityImageFluid-无法读取属性';流体';空的
我和理智和盖茨比一起工作 我正在尝试映射一组图像,以便在图像库中显示它们。我的GraphQL查询正在工作,我能够显示单个图像,但收到错误:Graphql …GatsbySanityImageFluid-无法读取属性';流体';空的,graphql,gatsby,sanity,Graphql,Gatsby,Sanity,我和理智和盖茨比一起工作 我正在尝试映射一组图像,以便在图像库中显示它们。我的GraphQL查询正在工作,我能够显示单个图像,但收到错误:TypeError:当我尝试映射数组时,无法读取null的属性'fluid' 任何方向都非常感谢 我的问题是: { 卫生室{ 图像{ 资产{ 流质{ …GatsbySanityImageFluid } } } } } 这项工作: const images=data.sanityGallery.images 这并不是: const images=data.s
TypeError:当我尝试映射数组时,无法读取null的属性'fluid'
任何方向都非常感谢
我的问题是:
{
卫生室{
图像{
资产{
流质{
…GatsbySanityImageFluid
}
}
}
}
}
这项工作:
const images=data.sanityGallery.images
这并不是:
const images=data.sanityGallery.images
{images.map((图像,索引)=>{
console.log(image.asset.fluid);//尝试以下方法:
const images = data.sanityGallery.images
<div className="img-container">
{images.map((image, index) => {
console.log(image.asset); //
return (
<div className="box">
{image.asset && <Img className="grow" fluid={image.asset.srcSet} key={index} />}
</div>
)
})}
</div>
const images=data.sanityGallery.images
{images.map((图像,索引)=>{
console.log(image.asset);//
返回(
{image.asset&&}
)
})}
现在它给了我错误:TypeError:无法读取null的属性'srcSet'
尝试:{image.asset&&}
代码不会中断,但我想知道它是否仍然显示图像。可能有一个损坏的图像中断了代码,而其余的(您提供的输出)正常工作