1. 使用antd

安装antd: npm install antd —save

  1. import React, { Component } from 'react'
  2. import { Button } from 'antd'
  3. import 'antd/dist/antd.css'
  4. import {GooglePlusOutlined,UsergroupAddOutlined,TagsOutlined} from '@ant-design/icons';
  5. export default class App extends Component {
  6. render() {
  7. return (
  8. <div style={{ padding: '20px', background: 'orange' }}>
  9. <Button type="primary">Primary Button</Button>
  10. <Button>Default Button</Button>
  11. <Button type="dashed">Dashed Button</Button>
  12. <GooglePlusOutlined />
  13. <TagsOutlined />
  14. <UsergroupAddOutlined />
  15. </div>
  16. )
  17. }
  18. }

使用npm run eject命令把react项目的webpack配置暴露出来:

2.css按需引入

参考官方文档:

image.png