React Native ListView加载不全

首先看了下DataSource ,数据没有问题,但是只能滑动一下才能加载完全。

官方的解决办法还没找到,用了一个别的办法先解决需求,之后再做研究。

初始化ListView

<ListView                    
    ref={(listview) => this.listView = listview}
    bounces={true}
    enableEmptySections={true}
    style={{width: width}}
    dataSource={dataSource}
    renderRow={this.renderRow.bind(this)}
    contentContainerStyle={{flexDirection: 'row', flexWrap: 'wrap', justifyContent:'space-between'}}
/>

在componentDidUpdate 中对ListView进行一个像素的滚动

componentDidUpdate() {
    let scrollResponder = this.listView.getScrollResponder()
    scrollResponder.scrollTo({y: 1, animated: true})
}

暂时能解决问题,之后再研究

猜你喜欢

转载自blog.csdn.net/MickeyChen_/article/details/82844869
今日推荐