【发布时间】:2020-01-27 03:49:12
【问题描述】:
我正在尝试为 Gatsby JS 中的 StaticQuery 钩子创建一个片段,但我不确定如何创建它。我尝试像这样创建另一个片段变量:
const fixedImage = graphql`
fragment fixedImage on File {
childImageSharp{
fixed{
...GatsbyImageSharpFixed
}
}
}
`
但我的查询仍然找不到片段,我也尝试将其作为参数传递,如下所示,但无济于事。
const data = ({fixedImage}) => useStaticQuery(graphql`
query MyQuery {
square1: file{
...fixedImage
}
square2: file{
...fixedImage
}
square3: file{
...fixedImage
}
square4: file{
...fixedImage
}
}
`)
【问题讨论】: