Reputation: 473
I have a json file with this structure:
[
{
"id": 1,
"name": "name1",
"address": "require(./assets/pic1.jpg)"
}
]
I import it:
import data from "./assets/test.json"
And then try to use as src for my image:
<img :src='item.address'>
But image doesn't appear. Could anybody say how to solve this problem?
Upvotes: 0
Views: 1278
Reputation: 893
You can solve this by changing your json file and image element:
[
{
"id": 1,
"name": "name1",
"address": 'pic1.jpg'
}
]
<img :src="require(`./assets/${item.address}`)" >
See more here: https://github.com/vuejs/Discussion/issues/202
Upvotes: 1