React native 我有一个通过API作为卡填充的平面列表,需要在每个卡上实现共享按钮,并在新屏幕上显示相应的数据
基本上,我有一个从远程api获得的工作平面列表数据&以卡的形式呈现。我在UI中添加了共享按钮,但无法理解 如何在每张卡上添加按键,单击该按钮可打开有关该特定卡的更多详细信息,或单击共享按钮可共享特定卡的数据或复制特定卡的数据React native 我有一个通过API作为卡填充的平面列表,需要在每个卡上实现共享按钮,并在新屏幕上显示相应的数据,react-native,React Native,基本上,我有一个从远程api获得的工作平面列表数据&以卡的形式呈现。我在UI中添加了共享按钮,但无法理解 如何在每张卡上添加按键,单击该按钮可打开有关该特定卡的更多详细信息,或单击共享按钮可共享特定卡的数据或复制特定卡的数据 <View> <FlatList data={this.state.dataSource} renderItem={({ item }) => <CardBox message
<View>
<FlatList
data={this.state.dataSource}
renderItem={({ item }) => <CardBox message={item} />}
keyExtractor={(item) => item.Id.toString()}
onEndReached={() => dispatchFetchPage()}
initialNumToRender={1}
maxToRenderPerBatch={2}
onEndReachedThreshold={0.5}
/>
</View>
<Card>
<CardItem button >
<View style={carddesign.card}>
<View>
<Text>Quote by : {this.props.message.author}</Text>
</View>
<View>
<Text style={carddesign.cardText}>{this.props.message.quote}</Text>
<Text style={carddesign.cardSubText}>{this.props.message.genre}</Text>
</View>
</View>
</CardItem>
<CardItem>
<Left style={{ flex: 1 }}>
<Button transparent onPress={ShareQuote}>
<Icon active name="share" />
<Text style={{ fontSize: 12 }}>Share</Text>
</Button>
</Left>
<Body style={{ flex: 1 }}>
<Button transparent>
<Icon active name="chatbubbles" />
<Text style={{ fontSize: 12 }}>Copy</Text>
</Button>
</Body>
<Right style={{ flex: 1 }}>
<Button transparent>
<Icon active name="download" />
<Text style={{ fontSize: 12 }}>Download</Text>
</Button>
</Right>
</CardItem>
</Card>
}
keyExtractor={(item)=>item.Id.toString()}
onEndReached={()=>dispatchFetchPage()}
initialNumToRender={1}
maxToRenderPerBatch={2}
onEndReachedThreshold={0.5}
/>
引用人:{this.props.message.author}
{this.props.message.quote}
{this.props.message.genre}
分享
复制
下载
您可以将卡组件包装在TouchableOpacity内,如下所示:
<TouchableOpacity onPress={this._onPressButton}>
<Card></Card>
</TouchableOpacity>
希望有帮助。您可以将卡组件包装在TouchableOpacity中,如下所示:
<TouchableOpacity onPress={this._onPressButton}>
<Card></Card>
</TouchableOpacity>
希望能有所帮助。谢谢你的回答,但我的问题是on-press函数,我不知道如何为单击的特定平面列表卡提取数据。没问题,只需在onPress函数中将项目作为参数传递,即onPress={this.onPressfunction.bind(this,item)}所以你可以得到你正在按下的特定项目。谢谢你的回答,但是我的问题是on-press函数,我不知道如何提取单击的特定平面列表卡的数据。没问题,只需将你的项目作为onPress函数中的参数传递,即onPress={this.onPressfunction.bind(this,item)}这样你就可以得到你要按下的特定项目。