调用element-plus的组件el-upload的clearFiles方法时,浏览器提示TypeError: uploadRef.value.clearFiles is not a function。
具体代码如下:
<el-upload ref="uploadRef"
:action="uploadUrl"
:on-success="successUpload"
:on-exceed="handleExceed"
:limit="item.limit">
<el-button type="primary">点击上传</el-button>
<template #tip>
<div class="el-upload__tip">
单个文件必须小于 20MB
</div>
</template>
</el-upload>
const handleExceed: UploadProps['onExceed'] = (files) => {
// debugger
if (uploadRef.value) {
uploadRef.value!.clearFiles() //清理上传列表
const file = files[0] as UploadRawFile
file.uid = genFileId()
console.log(file, file.uid)
uploadRef.value!.handleStart(file)
}
}