Why don't my images load in Vue.js 2?
This should work
<img :src="image" >
data () {
return {
image: require('@/assets/images/pin.svg')
}
},
Assuming you're using the webpack template from vue-cli
, you can simply use a relative path for static assets.
<img :src="'./assets/imgs/' + source + '.png'"
Alternatively, put your images in the static
directory and reference them with an absolute path, ie
<img :src="'/static/imgs/' + source + '.png'"