0

Hello i have a vue component where i loop in a list of countries like that :

<div v-for="i in pays" :key="i.id">
  {{i.name}}
  <span class="flag-icon-gr"></span>

And i would like to change the end of the flag-icon with the according label i receive from my loop. For example i would like to have flag-icon-fr if the country is france. Is there a proper way to do that ?

ps: im using nuxt but i guess it is the same for a normal vue js component.

1 Answer 1

2

You can bind the class dynamically using something like this:

<span :class=:icon="'fa-flag' + i.name"></span>
Sign up to request clarification or add additional context in comments.

1 Comment

exactly what i needed !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.