Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

react native上拉加载问题,在mate30上不行,其他机型可以(附代码)

代码如下,我没搞懂为什么这么写在其他机型上可以,在mate30上就不行,在mate30上拉到底部就没反应了,代码上有什么地方可以改了解决这个问题吗,在这里提前谢谢各位哥哥姐姐们的帮助了,小弟感激不尽!

 /**
     * 页面上拉触底事件的处理函数
     */
    pullUpLoad = (event) => {
        // return (<ActivityIndicator style={{height: 50}} animating={this.state.isLoadingMore} color="black" />);
        const contentHeight = event.nativeEvent.contentSize.height.toFixed(1);
        const scrollViewHeight = event.nativeEvent.layoutMeasurement.height;
        const scrollOffset = event.nativeEvent.contentOffset.y;

        const isEndReached = (scrollOffset + scrollViewHeight).toFixed(1) >= contentHeight; // 是否滑动到底部
        const isContentFillPage = contentHeight >= scrollViewHeight; // 内容高度是否大于列表高度
        if (isContentFillPage && isEndReached && this.scrollEnabled) {
            this.scrollEnabled = false;
            if (this.params.pageCount > this.params.page) {
                this.params.page++;
                this.myLoadData(true, this.params.page);
            } else {
                this.scrollEnabled = true;
                this.showInfo('没有更多数据');
                this.hideLoading(); //
                //提示到底
            }
        }
    }

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

1 Reply

0 votes
by (71.8m points)

真机调试的时候 打印下contentHeight,scrollOffset,scrollViewHeight 这几个属性,可能不一样


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...