简体   繁体   English

如何在 gatsby 中从 json 文件加载和显示本地 svg 图像?

[英]How to load and display local svg images from json file in gatsby?

I am trying to load local svg files from a json file inside my gatsby project but it's not displaying in the browser.我正在尝试从我的 gatsby 项目中的 json 文件加载本地 svg 文件,但它没有显示在浏览器中。 I can see 404 not found error in the console.我可以在控制台中看到 404 not found 错误。

Is there any way to solve this out?有没有办法解决这个问题?

It worked..:!有效..:! I put all the svg's inside the static folder which is outside the src folder and than in json file i just put the path :-我把所有的svg都放在了src文件夹之外的static文件夹中,而不是放在json文件中我只是放了路径:-

[{
    "id": "1",
    "title": "Test Post",
    "images": [
        {
            "src": "/bg1.svg"
        },            
    ]
}]

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

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