解决 cl-upload 在 form 分组下同个 prop 预览不显示问题

This commit is contained in:
icssoa 2024-02-21 16:43:34 +08:00
parent 3a55028265
commit 522aa17441
3 changed files with 13 additions and 9 deletions

View File

@ -16,7 +16,6 @@
class="cl-upload-item__image-cover"
fit="contain"
:src="item.preload || url"
lazy
@error="item.error = '加载失败'"
/>
</template>

View File

@ -355,17 +355,17 @@ async function httpRequest(req: any, item?: Upload.Item) {
toUpload(req.file, {
prefixPath: props.prefixPath,
onProgress(progress) {
item.progress = progress;
item!.progress = progress;
emit("progress", item);
}
})
.then((res) => {
Object.assign(item, res);
Object.assign(item!, res);
emit("success", item);
update();
})
.catch((err) => {
item.error = err.message;
item!.error = err.message;
emit("error", item);
});
}
@ -418,14 +418,19 @@ watch(
list.value = urls
.map((url, index) => {
const old = list.value[index] || {};
return Object.assign(
{
type: getType(url),
progress: 100,
uid: uuid(),
url
uid: uuid()
},
list.value[index]
old,
{
url,
preload: old.url == url ? old.preload : url //
}
);
})
.filter((_, i) => {

View File

@ -3,8 +3,8 @@ export default () => {
label: "文件上传",
description: "基于 el-upload 封装的文件上传组件",
author: "COOL",
version: "1.1.1",
updateTime: "2024-02-19",
version: "1.1.2",
updateTime: "2024-02-21",
demo: [
{
name: "基础用法",