I have an array of images returned from a API in my vue component, iterated and displayed like so:
<span v-for="pic in pics">
<img :src="'images/'+pic" onmouseover="highlight(pic)" :class="{isHovered = hovered}" />
</span>
In my script:
data(){
return {
pics: [],
hovered: false,
}
},
methods:{
highlight(pic){
this.hovered = true;
}
}
In my css
isHovered{
border: 2px solid red;
scale: 1.2;
cursor: pointer;
}
Problem is each time I hover over an image,all the images get the isHovered class. What I intended was to bind only the image hovered on to the isHovered class. What am i doing wrong please. Any guidance will be appreciated.