feat: 优化 UseIntersectionObserverInfiniteLoading 组件的加载逻辑和模板结构
Some checks failed
/ build-and-deploy-to-vercel (push) Failing after 39s
/ playwright (push) Successful in 2m1s
/ depcheck (push) Successful in 1m30s

This commit is contained in:
严浩
2024-12-11 15:48:35 +08:00
parent aa902ed159
commit dbcc28fb42

View File

@ -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) {