CondorUpload
CondorUpload 是一个支持单文件/多文件上传、文件预览、删除、从上传空间选择等功能。
组件 Props
| 参数名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| value | string / string[] / null / undefined | - | 必需 绑定的值,支持字符串(单文件)、数组(多文件)或null/undefined |
| multiple | boolean | false | 是否支持多文件上传 |
| max | number | 1 | 最大上传文件数量 |
| disabled | boolean | false | 是否禁用上传功能 |
组件事件
| 事件名 | 说明 | 参数 |
|---|---|---|
| update:value | 当文件列表变化时触发 | 更新后的值(字符串或字符串数组) |
基础用法
1. 单文件上传
vue
<template>
<div>
<h3>上传头像</h3>
<CondorUpload
v-model:value="avatarUrl"
:max="1"
/>
<p>当前头像: {{ avatarUrl }}</p>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const avatarUrl = ref('');
</script>2. 多文件上传
vue
<template>
<div>
<h3>上传产品图片</h3>
<CondorUpload
v-model:value="productImages"
:multiple="true"
:max="5"
/>
<p>已上传 {{ imageCount }} 张图片</p>
</div>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue';
const productImages = ref<string[]>([]);
const imageCount = computed(() => {
return Array.isArray(productImages.value) ? productImages.value.length : 0;
});
</script>