18

我正在尝试在本机反应中设置平面列表的刷新指示器,但不知道该怎么做。列表视图有这个道具:

refreshControl={<RefreshControl
                        colors={["#9Bd35A", "#689F38"]}
                        refreshing={this.props.refreshing}
                        onRefresh={this._onRefresh.bind(this)}
                    />
                }

但是平面列表只有这些:

refreshing={this.props.loading}
onRefresh={this._onRefresh.bind(this)}
4

3 回答 3

44

我找到了解决方案!它可能是虚拟的,但 FlatList 也有一个类似于 ListView 的名为 refreshControl 的道具,但我只是没有测试它!像这样:

 <FlatList
    refreshControl={<RefreshControl
                    colors={["#9Bd35A", "#689F38"]}
                    refreshing={this.props.refreshing}
                    onRefresh={this._onRefresh.bind(this)} />}
 />
于 2017-08-14T13:50:01.013 回答
0

您可以使用上面显示renderScrollComponent的相同组件将 传递给您的 FlatList 组件RefreshControl。我为此创建了一个博览会小吃:https ://snack.expo.io/rJ7a6BCvW

FlatList 在自身内部使用 VirtualizedList,对于 VirtualizedList 组件,它需要renderScrollComponenthttps ://facebook.github.io/react-native/docs/virtualizedlist.html#renderscrollcomponent

于 2017-08-13T22:59:45.120 回答
0

我正在传递bounces={false}给我的 Flatlist,这导致了问题。这将不允许您刷新。如果您想使用上述提到的一种解决方案,请将其删除。谢谢

于 2022-01-12T17:30:30.063 回答