解决 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" class="cl-upload-item__image-cover"
fit="contain" fit="contain"
:src="item.preload || url" :src="item.preload || url"
lazy
@error="item.error = '加载失败'" @error="item.error = '加载失败'"
/> />
</template> </template>

View File

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

View File

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