react ant icon的简单使用

refer: 快速上手 - Ant Design

1.引入ant

复制代码
npm install antd --save

2.在页面引用:

复制代码
import { StarOutlined } from '@ant-design/icons';

如果想要引入多个icon,可以这样书写:

复制代码
import { UserOutlined, MailOutlined, PieChartOutlined } from '@ant-design/icons';

上面这行代码就是在页面引入了ant的icon StarOutlined,在页面显示的是一个空心的星星

3.在需要的位置使用这个icon

复制代码
<Button type="primary" onClick={() => this.handleViewClick(record.id)}>

  <StarOutlined />

  查看

</Button>

上面这段代码是在查看这个button左侧增加了这个星星icon,如果你想设置css,例如居右8px等,可以使用:

复制代码
<StarOutlined style={{ marginRight: 8 }} />

如果是在''中引用,可以这样书写:

复制代码
{
    title: (
      <span>
        <StarOutlined style={{ marginRight: 8 }} />
        所属计算方案名称
      </span>
    ),
    dataIndex: 'calculation_plan_name',
    key: 'calculation_plan_name',
  },
相关推荐
GISer_Jing4 天前
AI驱动营销:业务技术栈实战(From AIGC,待总结)
前端·人工智能·aigc·reactjs
我即将远走丶或许也能高飞5 天前
reduxjs/toolkit 的学习使用
前端·javascript·学习·reactjs
GISer_Jing7 天前
2026前端技术潜在主流前沿方向
前端·人工智能·reactjs
可问春风_ren8 天前
前端文件上传详细解析
前端·ecmascript·reactjs·js
DEMO派13 天前
CSS优先级规则以及如何提升优先级方案详解
前端·javascript·css·vue.js·reactjs·html5·angular.js
Dontla14 天前
onlineconvertfree.com (convert images to icons)
icon
我的golang之路果然有问题16 天前
实习中遇到的 CORS 同源策略自己的理解分析
前端·javascript·vue·reactjs·同源策略·cors
Sun_小杰杰哇18 天前
Dayjs常用操作使用
开发语言·前端·javascript·typescript·vue·reactjs·anti-design-vue
web小白成长日记20 天前
前端三个月速成,是否靠谱?
前端·react.js·前端框架·html·reactjs·webkit·scss
前端不太难2 个月前
RN 与原生通信时出现性能瓶颈(Bridge 卡顿)怎么办?
前端·前端框架·reactjs