fix: 当图片404的时候不能初始化的问题

This commit is contained in:
xingyu4j
2025-06-18 15:16:46 +08:00
parent a311622334
commit 66d8690238

View File

@@ -44,6 +44,14 @@ const [Modal, modalApi] = useVbenModal({
if (isOpen) {
// 打开时,进行 loading 加载。后续 CropperImage 组件加载完毕,会自动关闭 loading通过 handleReady
modalLoading(true);
const img = new Image();
img.src = src.value;
img.addEventListener('load', () => {
modalLoading(false);
});
img.addEventListener('error', () => {
modalLoading(false);
});
} else {
// 关闭时,清空右侧预览
previewSource.value = '';
@@ -208,7 +216,7 @@ async function handleOk() {
>
<template #icon>
<div class="flex items-center justify-center">
<IconifyIcon icon="vaadin--arrows-long-h" />
<IconifyIcon icon="vaadin:arrows-long-h" />
</div>
</template>
</Button>