找不到gatsby图像svg [英] gatsby image svg not found

查看:84
本文介绍了找不到gatsby图像svg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试以这种方式加载SVG图像时:

When trying to load an SVG image this way:

export const query = graphql`
    query {
        fileName: file(relativePath: { eq: "logo_large.svg" }) {
            childImageSharp {
                fluid(maxWidth: 1060) {
                    ...GatsbyImageSharpFluid_withWebp_tracedSVG
                }
            }
        }
    }
`

我得到TypeError: Cannot read property 'childImageSharp' of null

如果我尝试完全相同但使用.jpg或.png图像,则它可以工作,因此相对路径必须正确. 关于SVG,我应该特别考虑些什么吗?

If I try the exact same but with a .jpg or .png image, it works, so the relative path must be correct. Any thing I should have in special consideration with SVG's?

推荐答案

出于明显的原因,该插件不支持SVG,它们是矢量的,不需要像这样的插件就可以自动调整大小.

SVG are not supported by this plugin for obvious reasons, they are vectorial and automatically adjust their size without the need of plugin like this one

这篇关于找不到gatsby图像svg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆