【发布时间】:2019-12-21 18:37:03
【问题描述】:
我是 gatsby 和 graphql 的新手。 尝试使用 graphql 获取图像,控制台正在返回图像日期, 但接下来我得到错误:
TypeError: Cannot read property '__reactstandin__key' of undefined
这是我获取 iamge 的代码:
export const fluidImage = graphql`
fragment fluidImage on File {
childImageSharp {
fluid(maxWidth: 1000) {
...GatsbyImageSharpFluid
}
}
}
`
export const pageQuery = graphql`
query {
myPhoto: file(relativePath: { eq: "me.png" }) {
...fluidImage
}
}
`
在渲染中
{console.log(this.props.data.myPhoto.childImageSharp.fluid)}
<Img fluid={this.props.data.myPhoto.childImageSharp.fluid} />
我得到带有 base64 数据的日志。 什么可能导致此错误?
【问题讨论】: