【发布时间】:2019-09-02 14:29:18
【问题描述】:
我有一个带有 3 个标签(标签 A、B、C)的应用。假设选项卡 A 有一个带有 ListHeaderComponent 的平面列表。当用户打开应用程序时,将首先显示选项卡 A。然后用户可以转到选项卡 B、选项卡 C。当用户返回选项卡 A 时,我想滚动到平面列表的顶部(不是索引 0),而是滚动到标题组件的最顶部。我试过了
this.refs.listRef.scrollToIndex({animated: true, index: 0, viewPosition: 0});
但它不起作用。以前有人做过吗?提前致谢。
【问题讨论】:
-
你想显示你配置的完整元素代码吗?
-
我可以举个例子:
<FlatList ref="listRef" extraData={this.state} ListHeaderComponent={this.headerComponent} renderItem={item => ( ... )} />
标签: react-native react-native-flatlist