0

It doesn't work. Why?

<img v-if="item.foto.src" v-bind:src="item.foto.src" width="{{item.foto.width}}" height="{{item.foto.height}}" />

This causes an error in browser, although the image is displayed

   <img v-if="item.foto.src" src="/{{item.foto.src}}" width="{{item.foto.width}}" height="{{item.foto.height}}" />

%7B%7Bitem.foto.src%7D%7D 404 (Not Found)

  • Possible duplicate of [Vue.js dynamic images not working](http://stackoverflow.com/questions/40491506/vue-js-dynamic-images-not-working) – Saurabh Feb 03 '17 at 03:24

1 Answers1

0

The first one would not produce a 404 (if the path was correct, you're missing the /), the second one would.

You'd need to do:

<img :src="'/' + item.foto.src">
Bill Criswell
  • 32,161
  • 7
  • 75
  • 66