I can not bind with image

1

Someone would explain to me why I was not able to render the image on the screen. I am using Vue-cli and the image is in the assets folder inside the normal folder, but when I call it in the template it does not load. I have already tried this: ./assets/produto.png , like this: ../assets/produto.png , like this: src/assets/produto.png . But without success!

Template:

<div>
  <img :src="imagem" :alt="alt">
</div>

Script:

data () {
  return {
    imagem: './assets/produto.png',
    alt: 'Imagens dos produtos.'
  }
}
    
asked by anonymous 01.10.2018 / 17:12

1 answer

0

People who have the same problem just put the images inside the static folder that is created by vue-cli on the same level as the assets folder.

Template:

<div>
  <img :src="imagem" :alt="alt">
</div>

Script:

data () {
  return {
    imagem: './static/produto.png',
    alt: 'Imagens dos produtos.'
  }
}
    
01.10.2018 / 18:30