'Adding vue.js to attribute src

I was trying to add the attribute src with vue.js to the img tag: <img v-bind:src="{object.url}"/> But for some reason the image is not loading.



Solution 1:[1]

Vue's syntax is unlike React's where you use {object.url} a lot.
In Vue, this is like this directly

<img :src="object.url" />

Solution 2:[2]

In a Vue template, a colon : prefixing an html attribute is a shorthand for v-bind. This allows you to use variables, computed etc. as attribute value instead of static values.

What you are trying is a react way which replace quotes around the attribute value with curly braces. But in Vue you can directly bind the variables without using curly braces.

Hence, It should be :

<img :src="object.url"/>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kissu
Solution 2 Rohìt Jíndal