我想通过导航发送参数。但是Im Im参数总是不确定的。我不知道要尝试什么,因为我真的不知道代码有什么问题。
这里是我发送参数的地方。
return (
<View>
{info.map((l, i) => (
<ListItem
key={i}
title={l.NombreCliente}
subtitle={
<TouchableOpacity onPress={() => navigation.navigate("Abonos", { id: l.idClientes})} >
<View
style={{
flexDirection: "row",
paddingLeft: 10,
paddingTop: 5
}}
>
<Text> Telefono: {l.Telefono} </Text>
<Text> Cumpleaños: {l.FechaDeNacimiento} </Text>
</View>
<View
style={{
flexDirection: "row",
paddingLeft: 10,
paddingTop: 5
}}
>
<Text> Total Vendido: {l.total} </Text>
<Text> Adeudo: {l.saldo_pendiente} </Text>
</View>
</TouchableOpacity>
}
bottomDivider
/>
))}
</View>
);
这里,我接收并显示参数。
const id = navigation.getParam("id");
console.log(id);
return(
<View>
<Text>
El id del cliente es: {id}
</Text>
</View>
);
我认为您必须从道具访问导航,并且应该是这样的:
const id = this.props.navigation.getParam("id");