Skip to content

zs-avatar 头像组件

功能描述

头像上传和显示组件,支持圆形和方形两种形状,支持图片上传和预览功能。

属性

属性名类型说明
avatarUrlstring头像 URL
shapestring头像形状,可选值为 circlesquare

事件

事件名说明参数
changeSuccess头像上传成功时触发上传成功的头像 URL

使用示例

vue
<template>
  <zs-avatar
    :avatarUrl="avatarUrl"
    shape="circle"
    @changeSuccess="handleChangeSuccess"
  />
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import ZsAvatar from '@/components/zs-avatar';

const avatarUrl = ref('');

const handleChangeSuccess = (url: string) => {
  avatarUrl.value = url;
  console.log('头像上传成功:', url);
};
</script>