系统环境

"antd": "^3.26.3",
"react": "^16.12.0",

升级准备

1.请将react版本升级到 React 16.12.0 以上。

2.请先升级到 3.x 的最新版本。 我这里升级到3.26.12

npm update antd@3.26.12

升级开始

1.先npm start确保项目可以正常运行。

2.关闭运行。确保全部代码已提交。
3.

npx -p @ant-design/codemod-v4 antd4-codemod src

4.升级结束后提醒我们安装

----------- antd4 dependencies alert -----------

Please install the following dependencies:

* antd^4.0.0-rc.0
* @ant-design/compatible^0.0.1-rc.0

----------- additional dependencies alert -----------

5.我们直接安装

yarn add @ant-design/compatible
yarn upgrade antd --latest

6.查看代码,发现Icon的引入方式变了

import { Icon as LegacyIcon } from '@ant-design/compatible';


<LegacyIcon type="info-circle" />

以及Form

import { Form } from '@ant-design/compatible';
import '@ant-design/compatible/assets/index.css';
//使用方式没变。

从 v3 到 v 4

相关文章:

  • 2021-09-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2021-06-24
  • 2021-12-19
  • 2021-07-07
猜你喜欢
  • 2022-01-12
  • 2022-12-23
  • 2021-09-19
  • 2022-01-16
  • 2021-05-14
  • 2022-01-15
相关资源
相似解决方案