在 React-Native 内滚动到页面顶部

Scroll to top of page in React-Native

在本机页面中,如果我触摸第二个列表中的任何项目(在 Header 之后),我必须显示页面的顶部(第一个列表 - 在顶部)。我试过this.refs.listRef.scrollTo({x: 0, y: 0, animated: true}),但没有解决我的问题

<Content>
          <ScrollView ref="listRef">
            <View style={{backgroundColor:'#e0e0e0'}}>
              {InvoiceStore.invoice_response2==2?<View>
              {InvoiceStore.invoice.length>0?
                <View style={{width:deviceWidth-(deviceWidth/50),
            padding:deviceWidth/70,alignSelf:'center',backgroundColor:'white',elevation:5,marginTop:deviceHeight/60,marginBottom:deviceHeight/60}}>
                  <List dataArray={InvoiceStore.invoice.slice()}
                    renderRow={(data) =>((data.length!=0)?<ListItem>................................................................................................................................................................... </ListItem>
                    :<View></View>)}>
                  </List>
                </View>
              :<View></View>}
              </View>:<Spinner/>}
            </View>



<Header style={{backgroundColor:'#d0964b',height:30}}>.......</Header>
{InvoiceStore.invoice_response2==2?<View>
              {InvoiceStore.invoice.length>0?
                <View style={{width:deviceWidth-(deviceWidth/50),
            padding:deviceWidth/70,alignSelf:'center',backgroundColor:'white',elevation:5,marginTop:deviceHeight/60,marginBottom:deviceHeight/60}}>
                  <List dataArray={InvoiceStore.invoice.slice()}
                    renderRow={(data) =>((data.length!=0)?<ListItem>................................................................................................................................................................... </ListItem>
                    :<View></View>)}>
                  </List>
                </View>
              :<View></View>}
              </View>:<Spinner/>}

</ScrollView>

在我滚动到底部的第二个列表中,上面的列表和 Headers 被隐藏了。如果我单击第二个列表中的任何项目,该数据在页面开始(第一个列表)中可见,为此我已将屏幕滚动到项目单击顶部。

有没有其他办法....

删除 ContainerContent 组件后才起作用