zs-avatar 头像组件
功能描述
头像上传和显示组件,支持圆形和方形两种形状,支持图片上传和预览功能。
属性
| 属性名 | 类型 | 说明 |
|---|---|---|
| avatarUrl | string | 头像 URL |
| shape | string | 头像形状,可选值为 circle 或 square |
事件
| 事件名 | 说明 | 参数 |
|---|---|---|
| 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>