AvatarStack 头像组
头像组组件用于显示一组头像,通常可用于显示活动用户、好友信息等等。
导入
js
import AvatarStack from '@/components/display/AvatarStack.vue'用法
基础用法
通过 urls 属性设置头像图片数组,round 属性设置圆形头像。
vue
<template>
<AvatarStack :urls="[
'https://imengyu.top/assets/images/test/2.jpg',
'https://imengyu.top/assets/images/test/3.jpg',
'https://imengyu.top/assets/images/test/4.jpg',
'https://imengyu.top/assets/images/test/5.jpg',
]" round />
</template>自定义大小
通过 size 属性设置头像组的大小。
vue
<template>
<AvatarStack :urls="[
'https://imengyu.top/assets/images/test/2.jpg',
'https://imengyu.top/assets/images/test/3.jpg',
'https://imengyu.top/assets/images/test/4.jpg',
'https://imengyu.top/assets/images/test/5.jpg',
]" round :size="100" />
</template>方形形状
通过 round=false 属性设置方形头像。
vue
<template>
<AvatarStack :urls="[
'https://imengyu.top/assets/images/test/2.jpg',
'https://imengyu.top/assets/images/test/3.jpg',
'https://imengyu.top/assets/images/test/4.jpg',
'https://imengyu.top/assets/images/test/5.jpg',
]" :round="false" />
</template>头像组超出后显示数字
通过 maxCount 属性设置最大显示的头像数量,超出部分会显示数量。
vue
<template>
<AvatarStack :urls="[
'https://imengyu.top/assets/images/test/2.jpg',
'https://imengyu.top/assets/images/test/3.jpg',
'https://imengyu.top/assets/images/test/4.jpg',
'https://imengyu.top/assets/images/test/5.jpg',
'https://imengyu.top/assets/images/test/2.jpg',
'https://imengyu.top/assets/images/test/3.jpg',
'https://imengyu.top/assets/images/test/4.jpg',
'https://imengyu.top/assets/images/test/5.jpg',
]" :maxCount="6" />
</template>边框
通过 border 和 borderWidth 属性设置头像边框。
vue
<template>
<AvatarStack :urls="[
'https://imengyu.top/assets/images/test/2.jpg',
'https://imengyu.top/assets/images/test/3.jpg',
'https://imengyu.top/assets/images/test/4.jpg',
'https://imengyu.top/assets/images/test/5.jpg',
'https://imengyu.top/assets/images/test/2.jpg',
'https://imengyu.top/assets/images/test/3.jpg',
'https://imengyu.top/assets/images/test/4.jpg',
'https://imengyu.top/assets/images/test/5.jpg',
]" :maxCount="6" round :border="true" :borderWidth="10" />
</template>设置头像之间的间距
通过 imageMargin 属性设置头像之间的间距。
vue
<template>
<AvatarStack :urls="[
'https://imengyu.top/assets/images/test/2.jpg',
'https://imengyu.top/assets/images/test/3.jpg',
'https://imengyu.top/assets/images/test/4.jpg',
'https://imengyu.top/assets/images/test/5.jpg',
]" :round="false" :imageMargin="25" />
</template>API 参考
AvatarStack
头像组组件。
Props
| 名称 | 说明 | 类型 | 必填 | 默认值 |
|---|---|---|---|---|
| defaultAvatar | 默认头像,在 url 为空或者加载失败时使用此头像 | string | - | '' |
| urls | 头像的图标URL数组 | string[] | 是 | [] |
| maxCount | 最大显示多少个头像,超过后显示数字 | number | - | 5 |
| showOverflowCount | 超过最大显示后是否显示数字 | boolean | - | true |
| imageMargin | 设置头像之间的距离,默认是 size/3 | number | - | 0 |
| size | 头像的大小 | number | - | 70 |
| round | 头像是否是圆形的 | boolean | - | true |
| radius | 头像是圆角的大小,仅在 round=false 时有效 | number/string | - | '50%' |
| border | 是否为头像添加边框 | boolean | - | false |
| borderWidth | 头像边框宽度 | number | - | 10 |
| borderColor | 头像边框颜色 | string | - | 'white' |
| overflowCountStyle | 超出显示文字背景样式 | object | - | {} |
| overflowCountTextStyle | 超出显示文字自定义样式 | object | - | {} |
| preview | 是否可以点击放大预览 | boolean | - | false |
Events
| 名称 | 说明 | 参数 |
|---|---|---|
| click | 点击头像事件 | index: number |
主题变量
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| AvatarStackSize | number | 70 | 头像默认大小 |
| AvatarStackRound | boolean | true | 头像默认是否为圆形 |
| AvatarStackRadius | string | '50%' | 头像默认圆角值 |
| AvatarStackMaxCount | number | 5 | 最大显示头像数量 |
| AvatarStackShowOverflowCount | boolean | true | 超过最大显示后是否显示数字 |
| AvatarStackBorder | boolean | false | 是否显示头像边框 |
| AvatarStackBorderWidth | number | 10 | 头像边框宽度 |
| AvatarStackBorderColor | string | 'white' | 头像边框颜色 |
| AvatarStackOverflowCountBackgroundColor | string | 'white' | 超出数量显示的背景色 |
| AvatarStackOverflowCountTextFontSize | number | 12 | 超出数量显示的文字大小 |
| AvatarStackOverflowCountTextColor | string | 'text.content' | 超出数量显示的文字颜色 |