- 安装
cnpm i antd --save
import { Button } from 'antd';function App() {return (<div className="App"><Button type="primary">Primary</Button></div>);}
### 按需加载
- 手动
- 拉取配置
- npm run eject: 拉取react的配置文件 y (如果有异常 删除 .git)
- 安装 cnpm install babel-plugin-import —save-dev
- 修改 package.json 中的 babel
"babel": {"presets": ["react-app"],"plugins": [["import",{"libraryName": "antd","libraryDirectory": "es","style": "css"}]]},
- import { Button } from ‘antd’; 直接引用即可, 不许再引入css
