Skip to content

CondorUpload

CondorUpload 是一个支持单文件/多文件上传、文件预览、删除、从上传空间选择等功能。

组件 Props

参数名类型默认值说明
valuestring / string[] / null / undefined-必需 绑定的值,支持字符串(单文件)、数组(多文件)或null/undefined
multiplebooleanfalse是否支持多文件上传
maxnumber1最大上传文件数量
disabledbooleanfalse是否禁用上传功能

组件事件

事件名说明参数
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>