I'm using VueJS in version 2.6.11 with vue-material 1.0.0-beta-11.
I've read through the internet about loading images into Vue through vue-loader etc. but none of that helped.
<md-card-media md-ratio="4:3">
<img :src="getImgUrl(muscle.name)" alt="Skyscraper">
</md-card-media>
This is my HTML element which is supposed to render images.
The getImgUrl is defined in such a way:
methods: {
getImgUrl: imgName => {
let urlName = imgName.replace(/\s/g, '')
return require(`@/assets/images/${urlName}.png`)
}
}
The result of the code above:
<img src="data:image/png;base64,dmFyIHJlbmRlciwgc3RhdGljUmVuZGVyRm5zCnZhc...truncatedForReadibility" alt="Skyscraper" crossorigin="Anonymous">
vue.config.js
module.exports = {
publicPath: '/siluets/',
configureWebpack: {
module: {
rules: [
{
test: /\.(png|jpe?g|gif)$/i,
loader: 'vue-loader',
options: {
esModule: false,
},
},
],
}
}
}
The browser is not showing up any images. I can't figure it out by myself
webpack.config.jsorvue.config.jscrossoriginattributeurl-loader/file-loaderby default