• 安装
    1. cnpm i antd --save
    1. import { Button } from 'antd';
    2. function App() {
    3. return (
    4. <div className="App">
    5. <Button type="primary">Primary</Button>
    6. </div>
    7. );
    8. }

    ### 按需加载

    1. 手动
    2. 拉取配置
    • npm run eject: 拉取react的配置文件 y (如果有异常 删除 .git)
    • 安装 cnpm install babel-plugin-import —save-dev
    • 修改 package.json 中的 babel
    1. "babel": {
    2. "presets": [
    3. "react-app"
    4. ],
    5. "plugins": [
    6. [
    7. "import",
    8. {
    9. "libraryName": "antd",
    10. "libraryDirectory": "es",
    11. "style": "css"
    12. }
    13. ]
    14. ]
    15. },
    • import { Button } from ‘antd’; 直接引用即可, 不许再引入css