react-native得flatList如何滚动到顶部

孔安福
2023-12-01
// 通过ref属性 调用scrollToOffset方法
let flat = ''
 < FlatList
        ref={(flatList) => { flat = flatList }}
         data={this.props.lockRoom.prizeList}
          renderItem={({ item }) => this.renderItem(item)}
         keyExtractor={(item) => item.orderId}
          ListFooterComponent={this.renderFooter}
          refreshing={this.state.refreshing}
          onRefresh={this.onRefresh}
         onEndReached={this.onEndReached}
                />
    flat.scrollToOffset({ offset: 0 }) // 滚动到顶部
 类似资料: