From 01183e1208822f8567e11c6777d53de8ebb2fd27 Mon Sep 17 00:00:00 2001 From: inottn Date: Thu, 25 Apr 2024 10:08:48 +0800 Subject: [PATCH] fix(ImagePreview): swipeItem may be undefined (#12818) --- packages/vant/src/image-preview/ImagePreviewItem.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/vant/src/image-preview/ImagePreviewItem.tsx b/packages/vant/src/image-preview/ImagePreviewItem.tsx index 229cca488..15ed76f3a 100644 --- a/packages/vant/src/image-preview/ImagePreviewItem.tsx +++ b/packages/vant/src/image-preview/ImagePreviewItem.tsx @@ -255,6 +255,9 @@ export default defineComponent({ const checkClose = (event: TouchEvent) => { const swipeItemEl: HTMLElement = swipeItem.value?.$el; + + if (!swipeItemEl) return; + const imageEl = swipeItemEl.firstElementChild; const isClickOverlay = event.target === swipeItemEl; const isClickImage = imageEl?.contains(event.target as HTMLElement);