[Vuejs]-Trying to set a dynamic url as backgroundImage in vuejs in v-for

0πŸ‘

:style="`backgroundImage: url('https://www.countryflags.io/${country.country_code}/flat/64.png')`"

-1πŸ‘

Is that the exact code you are using? If so, it looks like the issue is within the quotation marks on your url request.

You have

:style="{backgroundImage: 'url('https://www.countryflags.io/{{country.country_code}}/flat/64.png')'}"

Remove the quotes around the url and it should work

:style="{backgroundImage: 'url(https://www.countryflags.io/{{country.country_code}}/flat/64.png)'}"

Leave a comment