文档
问题描述
当指定了参数:limit=1
,就无法进行第二次上传
以下是官方文档给出的解决示例
通过on-exceed
来定义超出限制时的行为
<template> <el-upload ref="upload" :limit="1" :on-exceed="handleExceed" :auto-upload="false" > </el-upload> </template> <script setup lang="ts"> import { ref } from 'vue' import { genFileId } from 'element-plus' import type { UploadInstance, UploadProps, UploadRawFile } from 'element-plus' const upload = ref<UploadInstance>() const handleExceed: UploadProps['onExceed'] = (files) => { upload.value!.clearFiles() const file = files[0] as UploadRawFile file.uid = genFileId() upload.value!.handleStart(file) } const submitUpload = () => { upload.value!.submit() } </script>