Failed to compile
来源:5-5 Loading组件使用

Wentao_SU
2020-03-21
Failed to compile
./src/pages/ui/loading.js
Attempted import error: ‘Icon’ is not exported from ‘antd’.
现在是2020年3月了, 是不是组件更新了视频中的代码现在不管用了?
我的代码如下:
写回答
1回答
-
河畔一角
2020-03-21
您好,目前antd升级到4.0了,很多语法已经不能生效了,如果您公司目前也在使用antd框架,建议不要轻易升级,最好保持3.0版本用一段时间;
针对antd4.0升级后的问题,我下周会梳理一些出来,挨个补录一些视频在课程最后,到时候您可以从新观看一下;
针对目前您这个问题,我下面给您列出答案:
当需要在Button组件上面添加icon图标的时候,不能在用icon="plus"这样的配置了,必须单独引入Icon组件库才可以;
···
import { PlusOutlined } from '@ant-design/icons';
<Button type="primary" icon={<PlusOutlined />} >按钮</Button>
···
关于所有的图标,可以参考官网这个链接:
https://ant.design/components/icon-cn/#header00
相似问题