I have a list of gallery images and I want to be able to select an image to make it preview: true By default, there always has to be a preview image.
What I am trying to is
- Click the image
- Remove the preview on all images
- Make the clicked image a preview
- Update API
This is the code I'm trying to get to work:
export default {
props: ['images'],
methods: {
makePreview (image, index) {
// Loop through images and remove preview
this.images.map((image, index) => {
image.preview = false
})
// Set clicked image to preview
image.preview = true
// Update API
this.updateImages()
}
}
}
When I console.log(image) in the method, I do get the correct image object to update, but this is not updating the images prop.
EDIT:
Image object:
{
alt: "New venue"
id: 111
large: "https://radnomcdn.com/large.jpg"
order: 2
preview: false
thumb: "https://radnomcdn.com/thumb.jpg"
}
imagesproperty contain? The exact structure?