Avatar 头像
代码演示
基本
loading
类型
loading
自动调整字符大小
loading
带徽标的头像
loading
Avatar.Group
loading
响应式尺寸
loading
API
Avatar
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| alt | 图像无法显示时的替代文本 | string | - | |
| gap | 字符类型距离左右两侧边界单位像素 | number | 4 | 4.3.0 |
| icon | 设置头像的自定义图标 | VNode | - | |
| shape | 指定头像的形状 | circle | square | circle | |
| size | 设置头像的大小 | number | large | small | default | { xs: number, sm: number, ...} | default | 4.7.0 |
| src | 图片类头像的资源地址或者图片元素 | string | VNode | - | VNode: 4.8.0 |
| srcSet | 设置图片类头像响应式资源地址 | string | - | |
| draggable | 图片是否允许拖动 | boolean | 'true' | 'false' | true | |
| crossOrigin | CORS 属性设置 | 'anonymous' | 'use-credentials' | '' | - | 4.17.0 |
| onError | 图片加载失败的事件,返回 false 会关闭组件默认的 fallback 行为 | () => boolean | - |
Tip:你可以设置
icon或children作为图片加载失败的默认 fallback 行为,优先级为icon>children
Avatar.Group
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| max | 设置最多显示相关配置,5.18.0 前可使用 参数 | { count?: number; style?: CSSProperties; popover?: PopoverProps } | - | 5.18.0 |
| size | 设置头像的大小 | number | large | small | default | { xs: number, sm: number, ...} | default | 4.8.0 |
| shape | 设置头像的形状 | circle | square | circle | 5.8.0 |