bug: ion-infinite-scroll when loadmore data error. ionInfinite will be trigger many many times.

Đang mở
#31,013 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu với bản tái hiện Vue/TypeScript được cung cấp, tập trung vào handler ionInfinite và lệnh gọi loadNextPage của nó khi yêu cầu trang 2 được mô phỏng bị từ chối. Xác minh rằng sự kiện infinite-scroll không lặp lại sau lỗi tải thêm; issue không nêu tệp nguồn nào trong repository hoặc test nào cần chạy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

ionitron: needs reproduction
Prerequisites
Ionic Framework Version

v8.x

Current Behavior

trigger many many times

Expected Behavior

do not trigger

Steps to Reproduce

pull up loadmore

Code Reproduction URL

1

Ionic Info

1

Additional Information
首页 {{ item.name }} <script setup lang="ts"> import { IonPage, IonList, IonButton, IonItem, IonHeader, IonTitle, IonToolbar, IonRefresher, IonContent, IonRefresherContent, RefresherCustomEvent, IonInfiniteScroll, IonInfiniteScrollContent, InfiniteScrollCustomEvent } from "@ionic/vue" import LoadStatus from '@/components/load-status/load-status.vue'; import {useLoadStatus} from "@/components/load-status/useLoadStatus" import {chevronDownCircleOutline} from "ionicons/icons" // 模拟请求数据的接口客户端 const loadImpl = async (endpoint: string, p: { page: number; size: number }) => { // 模拟网络请求延迟 await new Promise(resolve => setTimeout(resolve, 1000)); // throw new Error("接口请求失败"); // return [] console.log(`请求接口 ${endpoint},页码: ${p.page}, 每页大小: ${p.size}`); if (p.page >= 2) { throw new Error(`接口请求失败=${p.page}`); } // 模拟分页数据 const totalItems = 45; // 假设总共有45条数据 const start = (p.page - 1) * p.size const end = start + p.size const items = Array.from({length: totalItems}, (_, i) => ({id: i + 1, name: `数据项 ${i + 1}`})); return items.slice(start, end); // const start = (page - 1) * size; // const start = (curPage.value - 1) * pageSize; // const end = start + pageSize; // const items = Array.from({length: totalItems}, (_, i) => ({id: i + 1, name: `数据项 ${i + 1}`})); // return items.slice(start, end); }; // Dashboard 数据请求配置 const {data, status, error, hasMore, hasData, isLoadingMore, refresh, loadNextPage} = useLoadStatus({ fetcher: async (curPage, pageSize) => { // 支持分页 const res = await loadImpl('/dashboard', {page: curPage!, size: pageSize!}); return res; }, pageSize: 20, autoFetch: true }); const handleRefresh = (event: RefresherCustomEvent) => { refresh().then(() => { event.target.complete(); }); }; const ionInfinite = (event: InfiniteScrollCustomEvent) => { // generateItems(); // setTimeout(() => event.target.complete(), 500); console.log("触发上拉加载更多"); loadNextPage().then(() => { console.log("加载下一页完成"); event.target.complete(); // setTimeout(() => { // event.target.disabled = false // }, 2000) }) }; </script>
Ngôn ngữ chính
TypeScript
Star
52.8k
Fork
13.3k
Merge trung bình
3 ngày 1 giờ
Pull request đã merge (30 ngày)
86

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ionic-team/ionic-framework

Tất cả issue của ionic-team/ionic-framework

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.