Javascript Vue 1.0 src绑定

Javascript Vue 1.0 src绑定,javascript,vue.js,Javascript,Vue.js,它不起作用。为什么? <img v-if="item.foto.src" v-bind:src="item.foto.src" width="{{item.foto.width}}" height="{{item.foto.height}}" /> 这会在浏览器中导致错误,尽管会显示图像 <img v-if="item.foto.src" src="/{{item.foto.src}}" width="{{item.foto.width}}" height="{{i

它不起作用。为什么?

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

这会在浏览器中导致错误,尽管会显示图像

   <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(未找到)

第一个不会生成404(如果路径正确,则缺少
/
),第二个会生成404

您需要执行以下操作:

<img :src="'/' + item.foto.src">

这个答案应该有效,但如果您使用webpack并通过webpack提供图像,则可能会出现一些问题。可能存在重复的