I've started a new project using Vue-CLI 3 and Webpack 4. Everything works fine, but for some reason I'm not able to bind images. The structure that I have is so easy:
<div id="app">
<div v-for="item in items">
{{ item.name }}
<img :src="'../public/images/' + item.img">
</div>
</div>
And then, my items array. It comes from my Store in Vuex.
items = [
{
name: 'my-name-1',
img: 'image-1.png'
},
{
name: 'my-name-2',
img: 'image-2.png'
},
{
name: 'my-name-3',
img: 'image-3.png'
}
]
I've been playing with Webpack, because I guess the problem comes from there. I've changed some configurations, I've tested with diferents paths (./, ../, ~/...) but nothing works... What I'm doing wrong? Thanks in advance.
itemis out of scope/undefined in img, it's only bound inside the v-for div, therefor<img .. item.imgwill not workitems = [is your real code - that its not valid js/json (should be{items : [...]}) - see here for a working demo