11

Can someone help me with using the img tag with vue.js?

Per the vue.js documentation, I tried:

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

Here is my jsfiddle

Can someone help?

3

4 Answers 4

21

You need to remove the double bracket:

<img :src=imgURL>

You bind it with shorthand syntax, so we don't need 'v-bind' or '{{}}' braces, its beauty of VUE JS, ':' is used to bind.

Sign up to request clarification or add additional context in comments.

Comments

7

Try this

<img v-bind:src=imgURL>

Comments

4

Above answers are both right but it doesn't really explains why the OP's making a mistake.

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.

Short words: either use v-bind or double brackets {{ }}

Comments

0

Maybe you try to print an image from image binary code,

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.