0

嗨我有简单的发布列表,并希望浏览每个帖子到他们的页面。我正在使用react-navigation,但它看起来不适用于CardItem。我该如何解决它?这里是代码。所有配置都在MainNavigator中完美完成。如何使用react-navigation导航CardItem?

<Card> 


     <CardItem> 
       <Left> 
       <Thumbnail source={{uri: 'Image URL'}} /> 
       <Body> 
        <Text>NativeBase</Text> 
        <Text note>GeekyAnts</Text> 
       </Body> 
       </Left> 
      </CardItem> 
      <CardItem cardBody 
      onPress={() => this.props.navigation.navigate('post')} 
> 
       <Image source={{uri: 'Image URL'}} style={{height: 200, width: null, flex: 1}}/> 
      </CardItem> 
      <CardItem> 
       <Left> 
       <Button transparent> 
        <Icon active name="thumbs-up" /> 
        <Text>12 Likes</Text> 
       </Button> 
       </Left> 
       <Body> 
       <Button transparent> 
        <Icon active name="chatbubbles" /> 
        <Text>4 Comments</Text> 
       </Button> 
       </Body> 
       <Right> 
       <Text>11h ago</Text> 
       </Right> 
      </CardItem> 
      </Card> 

它没有显示任何错误,只是当你点击它不导航。

+0

你提供'在谁呈现navigation'你可以做到这一点的' Card'? –

+0

这将是很好,如果分享你的错误也让我们得到确切的问题。 –

+0

它不显示任何错误消息只是不导航 – Syuzanna

回答

0

如果要定位到特定的页面上的卡

<Container> 
<Content> 
    <TouchableHighlight onPress=(()=>{console.log('navigate)})> 
     **In Between you can render you card** 
     <Card/> 
    </TouchableHighlight> 
</Content> 
</Container> 

的点击可能是这可以帮助你

+0

它引发错误undefined不是一个对象this.props.navigation.navigate。这是我使用的线。 this.props.navigation.navigate(“Post”)}> – Syuzanna

+0

onPress =(()=> {this.props.navigation.navigate(“Post”)} –

+0

它仍然不是(())=> {this.props.navigation.navigate(“Post”)})这段代码在这一行中的语法错误是 – Syuzanna