In a VueJs 3 project I have a list of PNG images. I put the PNG images under src/assets/pngs/. In my Vue componente I build the list with a For loop and put the image name in the img src. In dev mode this works fine.
<div v-for="item in items" :key="item.id">
<div class="card">
<p class="hint">{{ item.name }}</p>
<img :src="makeImgPath(item.img_name)" alt="">
</div>
</div>
methods: {
makeImgPath(imgName) {
return '/src/assets/pngs/' + imgName + '.png';
}
}
When I build the application with npm run build I get a 404 for all images in the list when built. I have also noticed that the pngs folder and therefore the images are not copied to dist/asstes/. Why is this so and what can I do so that the pictures are copied to the dist folder.
Thanks in advance, Max.
yes, dynamic value image path's are not coping to dist folder in build process, I suggest to place move images into public folder and refer from it..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With