Javascript 无法读取属性';childImageSharp';未定义的
描述 我遇到一个本地错误,开发无法读取未定义的'childImageSharp'属性 复制步骤 运行:Javascript 无法读取属性';childImageSharp';未定义的,javascript,Javascript,描述 我遇到一个本地错误,开发无法读取未定义的'childImageSharp'属性 复制步骤 运行:gatsby develope 预期结果 预期结果是在事件部分下方显示图像“LATHURZ”。然而,这并没有发生。我收到上述错误“无法读取未定义的属性'childImageSharp' 实际结果 实际结果是未定义的结果 发生了什么。我已经检查了我的查询: query Images { image: file(relativePath: { eq: "lathurz.jpg" }) { chil
gatsby develope
预期结果
预期结果是在事件部分下方显示图像“LATHURZ”。然而,这并没有发生。我收到上述错误“无法读取未定义的属性'childImageSharp'
实际结果
实际结果是未定义的结果
发生了什么。我已经检查了我的查询:
query Images {
image: file(relativePath: { eq: "lathurz.jpg" }) {
childImageSharp {
fixed(width: 400) {
...GatsbyImageSharpFixed
}
fluid {
...GatsbyImageSharpFluid
}
}
}
}
我相信这是正确的,它在操场上的表现是正确的
环境
系统:
看看你的代码,我相信问题在于“pageQuery”实际上是两个独立的查询。 而不是:
export const pageQuery = graphql`
query indexQuery {
[...]
}
query Images {
image: file(relativePath: { eq: "lathurz.jpg" }) {
childImageSharp {
fixed(width: 400) {
...GatsbyImageSharpFixed
}
fluid {
...GatsbyImageSharpFluid
}
}
}
}
`
尝试:
export const pageQuery = graphql`
query indexQuery {
[...]
}
query Images {
image: file(relativePath: { eq: "lathurz.jpg" }) {
childImageSharp {
fixed(width: 400) {
...GatsbyImageSharpFixed
}
fluid {
...GatsbyImageSharpFluid
}
}
}
}
`
export const pageQuery = graphql`
query{
[...]
image: file(relativePath: { eq: "lathurz.jpg" }) {
childImageSharp {
fixed(width: 400) {
...GatsbyImageSharpFixed
}
fluid {
...GatsbyImageSharpFluid
}
}
}
}
`