导入错误:“图标"未从“antd"导出 [英] import error: 'Icon' is not exported from 'antd'
问题描述
我已经创建了一个 React 应用程序并且我正在使用 Ant-Design (antd),在我的一个项目文件中,我想使用该标签,但我不能.显然这是ANT V4上的问题.
I have created a react app and I'm using Ant-Design (antd), in one of my project files, I want to use the tag but I can't. Apparently this is a problem on the ANT V4.
我正在使用以下导入语句;
I'm using the following import statement;
import { Icon } from 'antd',
并收到以下错误:
Attempted import error: 'Icon' is not exported from 'antd'.
<小时>
是否有在 v4 中使用此标签的解决方案?
<小时>我知道我们可以导入每个图标,然后将其用作标签,但是如果我们有多个图标,它会给出很长的代码
is there a solution to use this tag in v4?
I know that we can import each icon and then use it as a tag but it gives a very long code if we have several icons
推荐答案
对于 v4 中的图标导入:
For icon import in v4:
从 @ant-design/icons
import { SmileOutlined } from '@ant-design/icons';
<SmileOutlined />
或使用兼容包
import { Icon } from '@ant-design/compatible';
<Icon type="smile" />
猜测第二个是否符合您的需求.
Guessing the second one fit your demand.
您可以查看升级文档从 v3 到 v4有关这方面的更多信息.
You can check the upgrade document from v3 to v4 for more information about this.
这篇关于导入错误:“图标"未从“antd"导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!