Javascript 在React Native中导航
我试图在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”导入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功能