I would like go display the images inside an array named "image" within another array named product.
So basically if a product contain an array of 3 images i would like to display 3 images ,etc...
here's my code
<template>
<div class="details">
<div class="container">
<div class="row">
<div class="col-md-12" v-for="(product,index) in products" :key="index">
<div v-if="proId == product.productId">
<h1>{{product.productTitle}}</h1>
<h2>{{product.productId}}</h2>
<img :src="product.image[0]" class="img-fluid">
</div>
</div>
<div class="col-md-12" v-for="(product,index) in products" :key="index">
<div v-if="proId == product.productId">
<img :src="product.image[1]" class="img-fluid">
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "details",
data() {
return {
proId: this.$route.params.Pid,
title: "details",
products: [
{
productTitle: "ABCN",
image: [
require("../assets/images/autoportrait.jpg"),
require("../assets/images/bagel.jpg")
],
productId: 1
},
{
productTitle: "KARMA",
image: [require("../assets/images/bagel.jpg")],
productId: 2
},
{
productTitle: "Tino",
image: [require("../assets/images/bagel2.jpg")],
productId: 3
},
{
productTitle: "EFG",
image: [require("../assets/images/bagel3.jpg")],
productId: 4
}
]
};
}
};
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
I im able to display information within the first array example the product title, the product id, but the only way i found to display more images from the second array is to duplicate my code in the vue template and change the value of the index "product.image[0]", "product.image[1]".
There must be a better way to do this...
Thank a lot for the help