react next antd引入自定义svg图片
这样不显示图标,代码里面也不显示,
报错 Warning: [@ant-design/icons] Should have component
prop or children
.
import { ReactComponent as centerSvg } from "./icon-infor-centre-28-px.svg";
这里去掉ReactComponent as 不显示图标,代码里面同样不显示,
报错 Warning: [@ant-design/icons] Should have component
prop or children
.
import { centerSvg } from "./icon-infor-centre-28-px.svg";
这样子写又报错Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of AntdIcon
.
但是可以显示的,
import centerSvg from "./icon-infor-centre-28-px.svg";
咋办,不显示到底哪里有问题
import React from "react";
import Icon from "@ant-design/icons";
import { ReactComponent as centerSvg } from "./icon-infor-centre-28-px.svg";
import { ReactComponent as homeSvg } from "./icons.svg";
import { ReactComponent as buySvg } from "./icons-3.svg";
import { ReactComponent as referralSvg } from "./icons-4.svg";
import { ReactComponent as setSvg } from "./icons-5.svg";
import { ReactComponent as aboutSvg } from "./icons-2.svg";
import { ReactComponent as NextArrowSvg } from "./icons-next-36-px-2.svg";
import { ReactComponent as PrevArrowSvg } from "./icons-previous-36-px.svg";
const CenterIcon = props => <Icon component={centerSvg} {...props} />;
const HomeIcon = props => <Icon component={homeSvg} {...props} />;
const BuyIcon = props => <Icon component={buySvg} {...props} />;
const ReferralIcon = props => <Icon component={referralSvg} {...props} />;
const SetIcon = props => <Icon component={setSvg} {...props} />;
const AboutIcon = props => <Icon component={aboutSvg} {...props} />;
const NextArrowIcon = props => <Icon component={NextArrowSvg} {...props} />;
const PrevArrowIcon = props => <Icon component={PrevArrowSvg} {...props} />;
export {
CenterIcon,
HomeIcon,
BuyIcon,
ReferralIcon,
SetIcon,
AboutIcon,
NextArrowIcon,
PrevArrowIcon
};