问题
I'm having a problem binding data to src attribute in image. This is my code where I have :src and trying to bind image to it. Also I printed this.image in created() and it is getting printed fine. Here is the code
<img class="d-block w-100" :src="image" />
export default {
name: 'How',
data(){
return{
image: '../../assets/img/how_to_oka_6.png'
}
}
}
回答1:
You should import that image since it considered as a module like :
<img class="d-block w-100" :src="image" />
export default {
name: 'How',
data(){
return{
image: require('../../assets/img/how_to_oka_6.png')
}
}
}
来源:https://stackoverflow.com/questions/55579284/vue-not-binding-data-to-image-src