cnpm i babel-plugin-import --save-dev
在根目錄下的package.json下的bable中添加相應代碼css
"babel": { "presets": [ "react-app" ], "plugins": [ "transform-runtime", [ "import", { "libraryName": "antd", "style": "css" } ] ] },
你就能按需加載antd組件了, 像這樣react
import { Button } from 'antd';