Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.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
Javascript 在React Native中导航_Javascript_Reactjs_React Native_React Navigation - Fatal编程技术网

Javascript 在React Native中导航

Javascript 在React Native中导航,javascript,reactjs,react-native,react-navigation,Javascript,Reactjs,React Native,React Navigation,我试图在react native中导航,这是我的源代码 从“React”导入React; 从“react navigation”导入{StackNavigator}; 从“react native”导入{Text,TouchableOpacity}; 从“./components/LoginForm”导入LoginForm; 从“/components/EmployeeList”导入EmployeeList; 从“/components/EmployeeCreate”导入EmployeeCre

我试图在react native中导航,这是我的源代码

从“React”导入React;
从“react navigation”导入{StackNavigator};
从“react native”导入{Text,TouchableOpacity};
从“./components/LoginForm”导入LoginForm;
从“/components/EmployeeList”导入EmployeeList;
从“/components/EmployeeCreate”导入EmployeeCreate;
常量AddButton=(参数)=>(
console.log(param)}>
添加
);
常量样式={
addButtonStyle:{
尺码:18,
marginRight:25,
颜色:“#007AFF”
},
头饰样式:{
fontWeight:'正常',
对齐自我:“中心”,
保证金左:50
}
};
常量RouterComponent=StackNavigator({
雇员名单:{
屏幕:员工列表,
导航选项:{
标题:“员工名单”,
headerTitleStyle:styles.headerTitleStyle,
headerLeft:null,
headerRight:AddButton()
}
},
员工创建:{
屏幕:EmployeeCreate,
导航选项:{
标题:“员工创建”
}
},
主页:{
屏幕:LoginForm,
导航选项:{
标题:“请登录”,
headerTitleStyle:styles.headerTitleStyle
}
}
});

导出默认路由组件在StackNavigator的EmployeeList组件中,可以定义如下导航选项:

navigationOptions: ({navigation}) => 
return {
  title: 'Employee List',
  headerTitleStyle: styles.headerTitleStyle,
  headerLeft: null,
  headerRight: AddButton(navigation)
}
然后在AddButton组件中,您已经可以使用navigation.navigate功能