-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InfiniteScroll 重复触发 loadMore 方法 #4355
Comments
你在 可以具体描述一下你期望的行为是什么样的么? |
看了下,应该是滚动的问题,第一次加载几页内容,滚动几屏后,在点击搜索或者下拉的时候,为了重新定义到之前滚动的地方,就要重复请求。如果加载几页,在滚动到首屏,点击下拉或者搜索就不会重复触发了。可以考虑每次查询数据返回之前scroll重置为0。 |
每次查询数据返回之前将scroll重置为0,确实是能解决该重复调用问题! |
在你发的这 demo 里,将 scroll 重置为 0 应该是最优也是最合理的方案了,因为你如果不把 scroll 重置掉,用户点了刷新按钮之后,列表还处在一个中间的位置,这也是不合逻辑的,而且已经不是 InfiniteScroll 的问题了 至于别的更优雅的解法,我来写个 demo 挂到文档上吧 |
可以参考这个 demo: 3db3a8a |
好的,我已经明白了,谢谢! |
为什么内容区域不够就要触发啊,好不合理 |
Version of antd-mobile
5.0.0-beta.24
Operating system and its version
No response
Browser and its version
No response
Sandbox to reproduce
https://codesandbox.io/s/nervous-gwen-6yk7u?file=/src/list.js
What happened?
1、加载多页数据之后,点击搜索按钮,就会频繁触发 loadMore 方法
2、加载多页数据之后,点击下拉框1,然后再点击取消按钮,也会频繁触发 loadMore 方法
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: