Yt-UI
首页
快速开始
组件文档
首页
快速开始
组件文档
  • 表单组件

    • 输入框 Input
    • 多行输入框 Textarea
    • 开关 Switch
    • 多选框组 CheckboxGroup
    • 单选框组 RadioGroup
    • 滑块 Slider
    • 选择器 Picker
    • 日历 Calendar
    • 表单 Form
  • 展示组件

    • 头像 Avatar
    • 徽标 Badge
    • 卡片 Card
    • 标签 Tag
    • 步骤条 Steps
    • 结果页 Result
    • 空状态 Empty
    • 虚拟列表 VirtualList
  • 交互组件

    • 按钮 Button
    • 悬浮按钮 FAB
    • 图标 Icon
    • 搜索 Search
    • 分段器 Segment
    • 轮播 Swiper
    • 指示点 Dots
  • 反馈组件

    • 加载 Loading
    • 弹窗 Popup
    • 遮罩层 Overlay
    • 通告栏 NoticeBar
  • 导航组件

    • 标签栏 Tabbar
    • 顶部标签栏 TopTabbar
    • 折叠面板 Collapse
    • 课程表 Schedule
  • 布局组件

    • 分割线 Divider
    • 链接 Line
    • 可移动视图 MovableView

yt-avatar 头像组件

属性

属性名类型默认值说明
urlstring''头像图片地址
themeThemeColor | 'none''none'主题颜色
circlebooleantrue是否为圆形头像
sizenumber60头像尺寸(单位:px)
fitImageMode'aspectFill'图片裁剪模式
showBadgebooleanfalse是否显示徽标
enableBadgeThemebooleantrue徽标是否使用头像主题
countnumber0徽标数字
overflowCountnumber99徽标封顶数字
dotbooleanfalse是否显示小红点
offsetnumber[][]徽标偏移量

事件

事件名参数说明
clicke: Event点击头像
load{ height: string; width: string }图片加载完成
errorerrMsg: string图片加载失败

示例

基本使用

<yt-avatar url="/avatar.png" />
<yt-avatar theme="forest" />
<yt-avatar theme="ocean" />
<yt-avatar theme="magic" />
<yt-avatar theme="blossom" />
<yt-avatar theme="sunshine" />
<yt-avatar theme="classic" />
<yt-avatar theme="forest-sky" />
<yt-avatar theme="ocean-sky" />
<yt-avatar theme="magic-sky" />
<yt-avatar theme="blossom-sky" />
<yt-avatar theme="sunshine-sky" />

尺寸和形状

<yt-avatar :size="100" theme="forest" />
<yt-avatar :size="80" :circle="true" theme="ocean" />
<yt-avatar :size="120" :circle="false" theme="magic" />

带徽标

<yt-avatar theme="blossom" :showBadge="true" :count="5" />
<yt-avatar theme="sunshine" :showBadge="true" :dot="true" />
<yt-avatar theme="classic" :showBadge="true" :count="120" :overflowCount="99" />

星空主题徽标

<yt-avatar theme="forest-sky" :showBadge="true" />
<yt-avatar theme="ocean-sky" :showBadge="true" :count="3" />
<yt-avatar theme="magic-sky" :showBadge="true" :enableBadgeTheme="false" />
<yt-avatar theme="blossom-sky" :showBadge="true" :dot="true" />
<yt-avatar theme="sunshine-sky" :showBadge="true" :count="8" />

事件处理

<yt-avatar
  theme="forest"
  @click="handleAvatarClick"
  @load="handleImageLoad"
  @error="handleImageError"
/>

完整示例

<yt-avatar
  url="https://example.com/user.jpg"
  theme="forest-sky"
  :size="80"
  :circle="true"
  fit="aspectFill"
  :showBadge="true"
  :count="3"
  :dot="false"
  :overflowCount="99"
  :offset="[5, 5]"
  :enableBadgeTheme="true"
  @click="onAvatarClick"
  @load="onImageLoad"
  @error="onImageError"
/>

偏移徽标

<yt-avatar theme="ocean" :showBadge="true" :count="8" :offset="[10, 5]" />

方形头像

<yt-avatar url="/avatar.jpg" :circle="false" :size="100" theme="magic" />
最近更新:: 2026/3/9 19:16
Contributors: CHEEMS, 2126340634
Next
徽标 Badge