我不知道如何将值从一个屏幕发送到另一屏幕,
这是我的代码
<TouchableOpacity
style={{
width:"100%",
height:"200%",
alignItems:'center',
justifyContent:'center',
backgroundColor:'green'
}}
onPress={() =>
this.props.navigation.navigate(
'cart',
{ food : this.state.item,
amount : this.state.ruppess
}
)
}>
<Text>Cart</Text>
</TouchableOpacity>
答案 0 :(得分:1)
尝试一下
发送值
this.props.navigation.navigate(
"cart",{
food: this.state.item,
amount: this.state.ruppes
}
);
在下一个屏幕上获取值
const food = this.props.navigation.getParam("food", "");
const amount = this.props.navigation.getParam("amount", "");