1.安装

cnpm i babel-plugin-import --save-dev

2.使用

在根目录下的package.json下的bable中添加相应代码

"babel": {
    "presets": [
      "react-app"
    ],
    "plugins": [
      "transform-runtime",
      [
        "import",
        {
          "libraryName": "antd",
          "style": "css"
        }
      ]
    ]
  },

3.重启项目  npm start

你就能按需加载antd组件了, 像这样

import { Button } from 'antd';

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-11-17
  • 2018-11-22
  • 2021-07-29
猜你喜欢
  • 2021-08-20
  • 2022-12-23
  • 2022-01-22
  • 2021-05-06
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案