Here is my code which is works as charm as possible:
<li class="icon-list">
<img src="../assets/apple.svg" alt="apple" class="icons">
</li>
<li class="icon-list">
<img src="../assets/google.svg" alt="google" class="icons">
</li>
I want to do above with dynamic loop. so I've used v-for and using :src and :alt.
<li v-for="icon in icons" class="icon-list">
<img class="icons" :src="'../assets/' + icon.src" :alt="icon.alt">
</li>
export default {
name: "Home",
data() {
return {
icons: [
{
src: "google.svg",
alt: "google"
},
{
src: "apple.svg",
alt: "apple"
}
]
};
}
};
However it does not load any images. Any suggestion?
:src="require('../assets/' + icon.src)"?srcwebpack parse the image to base64 instead of a url, while with:srche doesn't because it is getting parsed by vue to a URL, do you have a static public folder in your root path/assets/with the images in it? and also the fact that there are no errors is weird, you should see the image or get an error that the image path return 404 code.