Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法读取属性';childImageSharp';未定义的_Javascript - Fatal编程技术网

Javascript 无法读取属性';childImageSharp';未定义的

Javascript 无法读取属性';childImageSharp';未定义的,javascript,Javascript,描述 我遇到一个本地错误,开发无法读取未定义的'childImageSharp'属性 复制步骤 运行:gatsby develope 预期结果 预期结果是在事件部分下方显示图像“LATHURZ”。然而,这并没有发生。我收到上述错误“无法读取未定义的属性'childImageSharp' 实际结果 实际结果是未定义的结果 发生了什么。我已经检查了我的查询: query Images { image: file(relativePath: { eq: "lathurz.jpg" }) { chil

描述 我遇到一个本地错误,开发无法读取未定义的'childImageSharp'属性

复制步骤

运行:
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
        }
      }
    }
  }
`