// antd: 5.1.1
import React from "react"; // 1、自定义图片 // import Icon from '@ant-design/icons'; // import Logo from '@/assets/Logo.png' // import './index.scss' // 自定义修改图片css // const Iconfont = (props: {icon: string}) => { // const ele = <img className="logoImg" src={Logo} alt='' /> // return <Icon component={() => ele}/> // } // 2、使用antd import * as Icons from '@ant-design/icons'; const Iconfont = (props: {icon: string}) => { const { icon } = props const antIcon: { [key: string]: any } = Icons return React.createElement(antIcon[icon]) } export default Iconfont /* 使用: return { ...item, icon: item.icon ? <Iconfont icon={item.icon} /> : '' } */
标签:const,自定义,menu,design,import,antd,icon From: https://www.cnblogs.com/-roc/p/17021436.html