2👍
I’m used to put all images into the public folder, so I don’t need webpack to load images.
The path of the image is ‘/public/assets/img/london.jpg’
So, in any Vue component I can render the image using
<div>
<a href="#">
<img src="/assets/img/london.jpg" alt="london"/>
</a>
</div>
- [Vuejs]-I'm trying unsuccessfully to disable the dark theme in @nuxtjs/vuetify
- [Vuejs]-Input checkbox marked out of the box vuejs components
2👍
You can also directly require in your template.
<div>
<a href="#">
<img :src="require(`@/assets/img/london.jpg`)"/>
</a>
</div>
Note that the @ is your src/ folder.
1👍
When binding properties, the model or data type must be correct.
To bind :src, it must be a string or data model.
<div> <a href=""><img :src="'london.jpg'"></a></div>
or
<div> <a href=""><img src="img"></a></div>
or
export default {
data () {
return {
img: require('london.jpg')
}
}
}
<div> <a href=""><img :src="img"></a></div>
- [Vuejs]-Vue.js v class binding is overriding other bindings and not removing classes properly
- [Vuejs]-Sl-vue-tree + vue-cli3.1 on ie11
Source:stackexchange.com