Skip to content
Advertisement

With Vue.js, How to use a modal component inside v-for loop?

i made v-for loop cards with vue-Bootstrap.

in state, there are dummy. like this.

JavaScript

],

and here is my vue.js code

JavaScript

and js

JavaScript

i just wanna each card has its own modal ex) when i click ManU card, just one modal will be activated and it has ManU data but in my code, when i clicked a card, 3 modals was activated…. T1, ManU, Chelsea

how can i resole it?

Advertisement

Answer

Try to add ‘id’ in your Array, and put the ID of Array as a Key.

JavaScript

Or, change the key of loop :key=”team.name” if you won’t add ‘id’

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement