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(); //
                //提示到底
            }
        }
    }
阅读 1.5k
1 个回答

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

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题