mercredi 18 mars 2020

Vuejs : v-if with object

I got a problem regardings a v-if v-else in a vuejs project. THe component checking inside the CvData.experiences object if there is an object with the index but it seems to not work.

When i click on the button, the object [0] (for example) is created. When i console.log(cvData.experiences) i've got the object 0 in cvData.experiences. And when i click again on the same button, it removes the object 0 (that's what the function does)

here the code :

<v-btn
 v-if="cvData.experiences[index]"
 icon
 small
 outline
 color="primary"
 @click="addItem(index)"
>
 <v-icon>remove</v-icon>
</v-btn>
<v-btn
 v-else
 icon
 small
 outline
 color="primary"
 @click="addItem(index)"
>
 <v-icon>add</v-icon>
</v-btn>

I've got the Add button, but when i click, it doesn't change.

So before i click : cvData.experiences[index] is undefined after i click : cvData.experiences[index] is an object

Aucun commentaire:

Enregistrer un commentaire