ant-design-vue/components/upload/demo/max-count.vue

51 lines
1.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<docs>
---
order: 10
title:
zh-CN: 限制数量
en-US: Max Count
---
## zh-CN
通过 `maxCount` 限制上传数量当为 `1` 始终用最新上传的代替当前
## en-US
Limit files with `maxCount`. Will replace current one when `maxCount` is `1`.
</docs>
<template>
<a-space direction="vertical" style="width: 100%" size="large">
<a-upload
v-model:file-list="fileList"
list-type="picture"
:max-count="1"
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
>
<a-button>
<upload-outlined></upload-outlined>
Upload (Max: 1)
</a-button>
</a-upload>
<a-upload
v-model:file-list="fileList2"
list-type="picture"
:max-count="3"
action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
>
<a-button>
<upload-outlined></upload-outlined>
Upload (Max: 3)
</a-button>
</a-upload>
</a-space>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { UploadOutlined } from '@ant-design/icons-vue';
import type { UploadProps } from 'ant-design-vue';
const fileList = ref<UploadProps['fileList']>([]);
const fileList2 = ref<UploadProps['fileList']>([]);
</script>