Avatar 头像

Avatar 组件可以用来代表人物或对象, 支持使用图片,图标或者文字作为 Avatar

基础用法

使用 shapesize 属性来设置 Avatar 的形状和大小。

展示类型

支持使用图片,图标或者文字作为 Avatar。

回退行为

图片加载失败时的回退行为。

适应容器

当使用图片作为用户头像时,设置该图片如何在容器中展示。与 object-fit 属性一致

Avatar API

Avatar 属性

名称说明类型默认值是否必需
iconrepresentation type to icon, more info on icon component.string | ComponentNo
sizeavatar size.number | 'large' | 'default' | 'small''default'No
shapeavatar shape.'circle' | 'square''circle'No
srcthe source of the image for an image avatar.stringNo
src-setnative attribute srcset of image avatar.stringNo
altnative attribute alt of image avatar.stringNo
fitset how the image fit its container for an image avatar.'fill' | 'contain' | 'cover' | 'none' | 'scale-down''cover'No

Avatar 事件

名称说明类型
errortrigger when image load error.(e: Event) => void

Avatar 插槽

插槽名说明
defaultcustomize avatar content.