[Vuejs]-Vue js binding variable in img src

0👍

Have you tried referencing the assets directory relatively?

Like so:

<img :src="'@/assets/kaarten/' + card.img + '.png'"/>

Also, the card.show variable is true, isn’t it?

0👍

You need to require the path, like this:

<img v-if="card.show" :src="require('../../src/assets/kaarten/' + card.img + '.png')">

or better yet, use template literals for clarity:

<img v-if="card.show" :src="require(`../../src/assets/kaarten/${card.img}.png`)">

Leave a comment