ElementPlus el-upload上传组件on-change只触发一次
主要运用了:on-exceed方法
废话不多说,直接上代码
<el-uploadclass="avatar-uploader"action="":on-change="getFilesj":limit="1":auto-upload="false"accept="image/png, image/gif, image/jpg, image/jpeg":show-file-list="false"ref="uploadImage":on-exceed="handleExceed"><imgv-if="showImg":src="showImg"class="avatar"/><el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon></el-upload>
const uploadImage = ref(null);
function handleExceed(files) {uploadImage.value.clearFiles();const file = files[0];file.uid = genFileId();uploadImage.value.handleStart(file);
}