我想将包含多个图像的文件夹绑定到我的数据。
我有一些数据:
var jsonData = [{
"Mass": "3",
"Force": "3.1",
"Acceleration": "3"
}, {
"Mass": "3",
"Force": "4.1",
"Acceleration": "3"
}, {
"Mass": "4",
"Force": "4.1",
"Acceleration": "4"
}, {
"Mass": "4",
"Force": "4.1",
"Acceleration": "4"
}, {
"Mass": "0",
"Force": "0",
"Acceleration": "0"
}, {
"Mass": "0",
"Force": "0",
"Acceleration": "0"
}];
但是当我用graphql查询它们时,我只有一个字符串:“ ./relimages/first-data”
尽管,我的cardimages数据条目直接被视为图像。
如何让我的查询将其视为一个文件夹,而不仅仅是返回字符串。
我希望此代码能够正常工作:
[
{
"title": "data1",
"images" : "./relimages/first-data/",
"cardimages" : "./relimages/main-page-card-images/1.jpg",
},
{
"title": "data2",
"images" : "./relimages/second-data/",
"cardimages" : "./relimages/main-page-card-images/2.jpg",
},
{
"title": "data3",
"images" : "./relimages/third-data/",
"cardimages" : "./relimages/main-page-card-images/3.jpg",
}
]
这是我当前的GraphQL查询:
<h1>{data.title}</h1>
data.images.edges.map(image => return (<img src={image.node.childImageSharp.fluid.src}/>))
但是我的图像数据条目被视为字符串,而不是文件夹。这有可能吗?
错误是:
字段\“ images \”不能选择,因为类型\“ String \”没有子字段