Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

关于react的滚动条问题,出现会自动到顶部去,怎么解决?

我使用react hook 实现加载更多,手机到底部之后,请求数据,添加在列表数据中,但是滚动条会重新到顶部,我就又要滑动下来,怎么解决这个问题呢??

useEffect(() => {
  if (!houseLoading && houses) {
    if (houses.length) {
    //应该就是这里设置的时候,会闪屏,再滚动条到顶部去了
      setHouseLists([...houseLists, ...houses]);
      if (houses.length < page.pageSize) {
        setShowLoading(false);
      }
    } else {
      setShowLoading(false);
    }
  }
}, [houseLoading]);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...