fix: 🐛 修复文件上传打包报错的问题
修复文件上传打包报错的问题
This commit is contained in:
@@ -112,7 +112,7 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const modelValue = defineModel("modelValue", {
|
const modelValue = defineModel("modelValue", {
|
||||||
type: [Array] as PropType<UploadFile[]>,
|
type: [Array] as PropType<FileInfo[]>,
|
||||||
required: true,
|
required: true,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
});
|
});
|
||||||
@@ -131,6 +131,8 @@ watch(
|
|||||||
return {
|
return {
|
||||||
name: name,
|
name: name,
|
||||||
url: item.url,
|
url: item.url,
|
||||||
|
status: "success",
|
||||||
|
uid: getUid(),
|
||||||
} as UploadFile;
|
} as UploadFile;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -191,10 +193,7 @@ const handleProgress = (event: UploadProgressEvent) => {
|
|||||||
const handleSuccess = (fileInfo: FileInfo) => {
|
const handleSuccess = (fileInfo: FileInfo) => {
|
||||||
ElMessage.success("上传成功");
|
ElMessage.success("上传成功");
|
||||||
|
|
||||||
modelValue.value = [
|
modelValue.value = [...modelValue.value, { name: fileInfo.name, url: fileInfo.url } as FileInfo];
|
||||||
...modelValue.value,
|
|
||||||
{ name: fileInfo.name, url: fileInfo.url } as UploadFile,
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -224,6 +223,12 @@ function handleDownload(file: UploadUserFile) {
|
|||||||
FileAPI.download(url, name);
|
FileAPI.download(url, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取一个不重复的id */
|
||||||
|
function getUid(): number {
|
||||||
|
// 时间戳左移13位(相当于乘以8192) + 4位随机数
|
||||||
|
return (Date.now() << 13) | Math.floor(Math.random() * 8192);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.el-upload-list__item .el-icon--close {
|
.el-upload-list__item .el-icon--close {
|
||||||
|
|||||||
Reference in New Issue
Block a user