Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 在React Native中是否有使用导航传递多个参数的方法?_Reactjs_React Native_React Navigation - Fatal编程技术网

Reactjs 在React Native中是否有使用导航传递多个参数的方法?

Reactjs 在React Native中是否有使用导航传递多个参数的方法?,reactjs,react-native,react-navigation,Reactjs,React Native,React Navigation,我有一个组件,在单击以更改屏幕时使用导航。当我这样做时,我希望能够使用navigation.navigate传递几个参数 卡片组件 const Card = props => { return ( <TouchableOpacity activeOpacity={0.7} onPress={() => props.nav.navigate('ActivityScreen', {activityTitle: 'this is not working >:('

我有一个组件,在单击以更改屏幕时使用导航。当我这样做时,我希望能够使用navigation.navigate传递几个参数

卡片组件

const Card = props => {
    return (
    <TouchableOpacity activeOpacity={0.7} onPress={() => props.nav.navigate('ActivityScreen', {activityTitle: 'this is not working >:(', activityID: props.id})}>
        <View style={styles.card}>
            <Text style={styles.title}>{props.title}</Text>
            <View style={styles.insideCardView}>
                <Text>More Text</Text>
            </View>
        </View>
    </TouchableOpacity>
    );
}
const Card=props=>{
返回(
props.nav.navigate('ActivityScreen',{activityTitle:'这不起作用>:(',activityID:props.id})}>
{props.title}
更多文本
);
}
新屏幕(我想在其上显示我的信息)

从“React”导入React;
从“react native”导入{View,Text,StyleSheet};
常量活动屏幕=道具=>{
返回(
这是Avtivity页面
{
//这不起作用,没有错误,只是空白
}
{props.activityTitle}
{props.activityID}
);
}
如果是这样,这是最有效的方法吗


提前谢谢。

您必须使用
props.route.params.yourParamName来访问它。因此,请按以下方式编写代码:

从“React”导入React;
从“react native”导入{View,Text,StyleSheet};
常量活动屏幕=道具=>{
返回(
这是Avtivity页面
{
//这不起作用,没有错误,只是空白
}
{props.route.params.activityTitle}
{props.route.params..activityID}
);
}
import React from 'react';
import  {View, Text, StyleSheet} from 'react-native';

const ActivityScreen = props => {
    return (<View style={styles.header}>
        <Text>This is the Avtivity page</Text>
        {
            //This does not work, gives no error, just blank
        }
        <Text>{props.activityTitle}</Text>
        <Text>{props.activityID}</Text>
    
    </View>);
}