1

How can I use object in img src?

// html
<img src= "item.img"

Sample

1 Answer 1

1

Below is a way to pass the url

<img :src="item.img"

if the above doesn't work then try the same using require just as below

<img :src="require(item.img)"

Assuming that item is an object with img property present in it

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

3 Comments

Cool, the above answer worked well. I didn't know the answer is adding the colon, thanks for the help.
Yes that way how you send dynamic values
@Inforage Great! If it works for you and you are happy - then in general you would accept the answer. This will not only help other people with the same issue but it will also mean people are more likely to help you in the future with any other issues you have. You can read about accepting here: stackoverflow.com/help/accepted-answer

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.