When I add an option to the cart, the counters of all the options increase at the same time. I tried with Vuex, but I'm inexperienced with it, so I took a simpler approach. How can I add an option without all the counters increasing?
(I put together an example of the code, so that it's easier to explain.)
<template>
<div>
<div v-for="optionTests in ArrayOption" :key="optionTests.id">
<p>{{ optionTests.id}}</p>
<p>{{ optionTests.name}}</p>
<p>{{ optionTests.description}}</p>
<button @click="testCount -= 1" :disabled="testCount < 1">-</button>
<p>{{ testCount }}</p>
<button @click="testCount += 1" :disabled="testCount > 0">+</button>
</div>
</div>
</template>
<script>
import axios from 'axios'
export default {
data(){
return{
ArrayOption:[
{
id:1,
name: 'option1'
description: 'je suis l option 1 ajoute moi au panier'
},
{
id:2,
name: 'option2'
description: 'je suis l option 2 ajoute moi au panier'
},
{
id:3,
name: 'option3'
description: 'je suis l option 3 ajoute moi au panier'
},
{
id:4,
name: 'option4'
description: 'je suis l option 4 ajoute moi au panier'
}
],
testCount:0,
}
}
}
