简体   繁体   English

img url with vue.js

[英]img url with vue.js

Can someone help me with using the img tag with vue.js? 有人可以帮我使用img标签和vue.js吗?

Per the vue.js documentation , I tried: 根据vue.js 文档 ,我试过:

<img v-bind:src={{ imgURL }}> //prints a null image

Here is my jsfiddle 这是我的jsfiddle

Can someone help? 有人可以帮忙吗?

您需要删除双括号:

<img :src=imgURL>

尝试这个

<img v-bind:src=imgURL>

Above answers are both right but it doesn't really explains why the OP's making a mistake. 以上答案都是正确的,但它并没有真正解释为什么OP犯了错误。

When you are using double brackets you are telling vue to do v-bind: so when you write v-bind and also use double brackets then you are double calling the same thus generating a mistaken behavior. 当您使用双括号时,您告诉vue执行v-bind:因此当您编写v-bind并使用双括号时,您将双重调用相同的内容,从而产生错误行为。

Short words: either use v-bind or double brackets {{ }} 简短的词:使用v-bind或双括号{{}}

也许您尝试从图像二进制代码打印图像,

<img v-bind:src="'data:image/Bmp;base64,' + obj1.Obj2.propImage" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM