From dbcc28fb4235149ef65d220922b73665c71cb252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Wed, 11 Dec 2024 15:48:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20UseIntersectionObs?= =?UTF-8?q?erverInfiniteLoading=20=E7=BB=84=E4=BB=B6=E7=9A=84=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E9=80=BB=E8=BE=91=E5=92=8C=E6=A8=A1=E6=9D=BF=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UseIntersectionObserverInfiniteLoading.vue | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/UseIntersectionObserverInfiniteLoading.vue b/src/components/UseIntersectionObserverInfiniteLoading.vue index fa7e01d..766bfe2 100644 --- a/src/components/UseIntersectionObserverInfiniteLoading.vue +++ b/src/components/UseIntersectionObserverInfiniteLoading.vue @@ -65,11 +65,10 @@ const load = async (why?: string) => { try { const { hasMore } = await props.asyncLoad(++currentPage); state.value = hasMore ? 'loaded' : 'complete'; - if (hasMore) { + if (hasMore && checkIsVisible(target.value!)) { await nextTick(); - if (checkIsVisible(target.value!)) { - load('visible after load'); - } + await new Promise((resolve) => setTimeout(resolve, 300)); + load('visible after load'); } if (!hasMore) {