在这里,我尝试在 Gatsby 的 Typescript 页面中使用 SVG。我正在使用这个插件https://www.gatsbyjs.com/plugins/gatsby-plugin-react-svg/。
//gatsby-config.js
{
resolve: "gatsby-plugin-react-svg",
options: {
rule: {
include: `${__dirname}/src/svg/`,
},
},
},
//test.tsx
import React from "react";
import Layout from "../components/layout";
import { Container } from "../components/box";
import SEO from "../components/seo";
import ReactSvg from "../svg/react.svg" ;
export default () => (
<Layout>
<SEO title="404: Not found" />
<Container>
<ReactSvg />
</Container>
</Layout>
);
我得到的错误👇