Hey there, I'm pretty new to Vue and could use some assistance with implementing a certain logic.
I have a JSON file that contains information about polaroids I've taken, such as their IDs, names, image names, and descriptions. Here's a snippet:
[
{
"id": "PRD1",
"image": "polaroid_1.jpeg",
"name": "Christmas - 2020",
"description": "blah blah blah"
},
{
"id": "PRD2",
"image": "polaroid_2.jpeg",
"name": "Lost Love - 2021",
"description": "Memories of a relationship that never was."
},
...
]
I have a component in which I use a v-for loop to render these images. Here's the full HTML code:
<template>
<div class="images-wrapper">
<div class="images" v-for="polaroid in polaroids" :key="polaroid">
<img class="polaroid-image" :src="getImgUrl(polaroid.image)"/>
<div class="information-wrapper">
<div class="polaroid-title">
{{ polaroid.name }}
</div>
<div class="polaroid-description">
{{ polaroid.description }}
</div>
</div>
</div>
</div>
The images are displayed perfectly in a grid within my Vue app. However, I'm unsure how to implement the logic that allows for clicking on an image to replace it with another image from the assets folder (e.g., polaroid_0.jpeg), and display the name and description of the clicked image.
Any suggestions on how to achieve this?
EDIT - Clarification
@FayçalBorsali Apologies for any confusion. To clarify, I want to be able to click on an image in the grid and have it switch to a different image, while also showing additional text (name and description). If I click the image again, it should revert back to the original image. Is it possible to have multiple selected images at once? For example, clicking on two different images to replace them with another image, while keeping the third image unchanged.