react-组件-Icon
1. 基本使用
1.1. 在 public 下 index.html 中引入该文件
图标库
1.2. 在 index.scss 中加入通用 css 代码
index.scss
1.3. 挑选相应图标并获取类名
2. 封装 Icon 组件
Icon/index.tsx
// 组件 props 的类型
type Props = {
// icon 的名称
type: string
// icon 的自定义样式
className?: string
// 点击事件
onClick?: () => void
}
const Icon = ({ type, className, onClick }: Props) => {
return (
)
}
export default Icon
| 参数 | 描述 | 类型 | 是否可选 |
|---|---|---|---|
| type | 图标的名称 | string | 否 |
| className | 图标的自定义样式 | string | 是 |
| onClick | 自定义点击事件 | ()=>void | 是 |