This is my JSON data which has the buttons and image URL mappings:
buttonDetails= [ {
"name": "button1",
"images": [{
"url": "https://localhost:8080/asset/d304904a-1bbd-11e6-90b9-55ea1f18bbbb.png"
},
{
"url": "https://localhost:8080/asset/d304904a-1bbd-11e6-90b9-55ea1f18bbbb.png"
},
{
"url": "https://localhost:8080/asset/d304904a-1bbd-11e6-90b9-55ea1f18bbbb.png"
}
]
},
{
"name": "button2",
"images": [{
"url": "https://localhost:8080/asset/d304904a-1bbd-11e6-90b9-55ea1f18bbbb.png"
},
{
"url": "https://localhost:8080/asset/d304904a-1bbd-11e6-90b9-55ea1f18bbbb.png"
},
{
"url": "https://localhost:8080/asset/d304904a-1bbd-11e6-90b9-55ea1f18bbbb.png"
}
]},
{
"name": "button3",
"images": [{
"url": "https://localhost:8080/asset/d304904a-1bbd-11e6-90b9-55ea1f18bbbb.png"
},
{
"url": "https://localhost:8080/asset/d304904a-1bbd-11e6-90b9-55ea1f18bbbb.png"
},
{
"url": "https://localhost:8080/asset/d304904a-1bbd-11e6-90b9-55ea1f18bbbb.png"
}
]
}]
Template Code which renders all the buttons and the image related to button1 while page loads:
<template>
<ul class="images-list" v-for="(button,index) in buttonDetails" v-if="index == button1">
<li v-for="image in button.images" v-if="image.style=='750WX750H'">
<img :src="image.url" alt="" @click="zoom1 = true" @mousemove="moveBG">
<div class="image-hover" :style="{ backgroundImage: 'url(' + image.url + ')' }"></div>
<modal v-model="zoom1" class="image-zoom">
<div>
<img :src="image.url" :style="{transform:'translateY(' + translateY + 'px)'}" @mousemove.self="onMouseMove($event)">
</div>
</modal>
</li>
</ul>
<ul class="button-list">
<li v-for="button of this.buttonDetails">{{button.name}}</a></li>
</ul>
</template>
So based on every button click I have to change the image source as per the given JSON in the Buttondetails variable. Kindly guide me.
Each and every button looped below has its associated images. Only one button and its corresponding images set will be active at a given point of time. Please help me in achieving this.
v-if="image.style=='750WX750H'so there is no style in JSON as well jsfiddle has error andtranslateYis missing, just make minimal markup what you needed rest remove, so code can run without error