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',
  },
相关推荐
Dragon Wu9 小时前
Electron Forge集成React Typescript完整步骤
前端·javascript·react.js·typescript·electron·reactjs
CappuccinoRose4 天前
React框架学习文档(七)
开发语言·前端·javascript·react.js·前端框架·reactjs·react router
yuezhilangniao5 天前
Next.js 项目运维手册-含-常用命令-常见场景
运维·开发语言·reactjs
智绘前端10 天前
GitHub 登录功能开发 SOP
人工智能·typescript·github·reactjs
GISer_Jing18 天前
AI驱动营销:业务技术栈实战(From AIGC,待总结)
前端·人工智能·aigc·reactjs
我即将远走丶或许也能高飞18 天前
reduxjs/toolkit 的学习使用
前端·javascript·学习·reactjs
GISer_Jing20 天前
2026前端技术潜在主流前沿方向
前端·人工智能·reactjs
可问春风_ren22 天前
前端文件上传详细解析
前端·ecmascript·reactjs·js
DEMO派1 个月前
CSS优先级规则以及如何提升优先级方案详解
前端·javascript·css·vue.js·reactjs·html5·angular.js
Dontla1 个月前
onlineconvertfree.com (convert images to icons)
icon