React native 如何";滚动至顶部“;在本地基地<;内容>;组件?

React native 如何";滚动至顶部“;在本地基地<;内容>;组件?,react-native,expo,native-base,React Native,Expo,Native Base,我正在使用Expo并在其上实现本机,每当“MainTabNavigator”图标 是否应在或(在MainTabNavigator中)中实现句柄?您可以检查响应本机键盘感知滚动视图的API和方法,因为这是的替换元素 试试这个 <Container> <Content ref={c => (this.component = c)}> <Text style={styles.text}>test</Text> &l

我正在使用Expo并在其上实现本机,每当“MainTabNavigator”图标


是否应在
(在MainTabNavigator中)中实现句柄?

您可以检查
响应本机键盘感知滚动视图的API和方法,因为这是
的替换元素

试试这个

 <Container>
    <Content ref={c => (this.component = c)}>
      <Text style={styles.text}>test</Text>
      <Text style={styles.text}>test</Text>
      <Text style={styles.text}>test</Text>
      ...
      ...
      ...
      ...

      <Button onPress={() => this.component._root.scrollToPosition(0, 0)}>
        <Text>Back to top</Text>
      </Button>
    </Content>
  </Container>

(this.component=c)}>
测试
测试
测试
...
...
...
...
this.component.\u root.scrollToPosition(0,0)}>
回到顶端

我试过这个,但运气不好。在Native Base的
Content.js
ref={c=>{this.\u scrollview=c;this.\u root=c;}}
但是在
doc
中它应该使用
{this.scroll=ref}>
最聪明的开发人员和你一样,兄弟。这是一项神奇的工作。谢谢。