I was looking around for a solution, but I don't get this working. So this is my structure in the graph query:
[
{
"titleGallery": "My title",
"yearGallery": {
"year": "2021",
"id": "49620627"
},
"tags": [
{
"id": "49700910",
"tag": "Photo"
}
],
"submitImages": [
{
"url": "https://website.com/53092/1627489520-m200820fine.jpg",
"title": null,
"alt": null
},
{
"url": "https://website.com/53092/1627637821-m201439fine.jpeg",
"title": null,
"alt": null
},
{
"url": "https://website.com/53092/1627633569-610268c72ec480634b8340ccm200633fine.jpeg",
"title": null,
"alt": null
}
],
"descriptionGallery": "My second title",
"id": "50404979",
"event": {
"id": "49621559",
"categoryName": "Category name"
}
}
]
So basically I want to have access to the array submitImages, so I can get the url in a v-for component. This is what I already try:
<tumb-img
v-for="(image,index) in imgGallery.submitImages"
:key="index"
:imageURL="image.url"></tumb-img>
So first trying direct access to the object imgGallery (which is a getter, and it is working...just in case). The other thing that I tried was to get the access with a computed instead like this
<tumb-img
v-for="image in getImgUrl"
:key="image.id"
:imageURL="image.url"></tumb-img>
the computed
getImgUrl(){
return this.imgGallery && this.imgGallery.submitImages
}
but certainly there is something wrong or missing here, because it's not working :) . Thank you in advance for your help
*** UPDATE ******
I also tried this, with 2 v-for, but also it's not working, I get message submitImages, was accessed during render but is not defined on instance. But maybe because I shouldn't be using directly there, the submitImages?
<div v-for="gallery in imgGallery" :key="gallery.id" >
<tumb-img
v-for="image in submitImages"
:key="image.id"
:imageURL="image.url">
</tumb-img>
</div>
imgGalleryrefer to the first object in your array, or the actual array itself?imgGalleryreturns an array, and you cannot accesssubmitImagesusing dot notation since it is not an object. usethis.imgGallery[0].submitImagesinstead, but this will only give you the submit images from the first nested object in your array.