Skip to content

Avatar 头像

基础用法

  • 用以展示用户头像。
vue
<template>
	<sn-avatar src="https://www.example.com/example.png" shape="circle" size="60px">
	</sn-avatar>
</template>

更多演示请下载 demo 查看

属性

参数说明类型默认值可选值
mode头像展示模式Stringimageimage | text | icon
imageMode图片模式下头像的裁剪方式String-scaleToFill |aspectFit |aspectFill |widthFix |heightFix |top |bottom |center |left |right |top left |top right |bottom left |bottom right
src图片模式下头像图片地址String--
text文本模式下头像内部文本String--
icon图标模式下头像内部图标名String--
size头像尺寸(外框的边长)String40px-
textSize文本模式下头像内部文本大小String25px-
textColor文本模式下头像内部文本颜色String$infoDark-
iconSize图标模式下头像内部图标大小String25px-
iconColor图标模式下头像内部图标颜色String$infoColor-
bgColor非图片模式下头像背景颜色String$info-
shape头像形状Stringsquaresquare | circle
borderRadius头像圆角大小(仅 shape="square" 时生效)String$xsmall-
enablePreview图片模式下启用图片预览Booleanfalsetrue | false
customStyle自定义头像样式UTSJSONObject{}-
customTextStyle自定义头像内部文本样式UTSJSONObject{}-
customIconStyle自定义头像内部图标样式UTSJSONObject{}-

事件

名称类型说明
click(e: UniPointerEvent) => void点击头像时触发
dbclick(e: UniPointerEvent) => void双击头像时触发
load(e: UniImageLoadEvent) => void头像加载完成时触发
error(e: UniImageErrorEvent) => void头像加载失败时触发
longpress(e: UniEvent) => void长按头像时触发

使用 MIT 协议