Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.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 在注册表后的第二个类中导航_Javascript_Reactjs_React Native_React Navigation - Fatal编程技术网

Javascript 在注册表后的第二个类中导航

Javascript 在注册表后的第二个类中导航,javascript,reactjs,react-native,react-navigation,Javascript,Reactjs,React Native,React Navigation,我正在尝试在两个屏幕之间导航,但我不知道在第一个屏幕之后如何导航。这个wuestion也是关于类的导航,因为所有的示例都只显示常量中的道具 文件:index.android.js const AppNative = props => { return <AppScreen navigation={props.navigation} />; }; const MyApp = DrawerNavigator( { Home: { screen: AppNative },

我正在尝试在两个屏幕之间导航,但我不知道在第一个屏幕之后如何导航。这个wuestion也是关于类的导航,因为所有的示例都只显示常量中的道具

文件:index.android.js

const AppNative = props => {
 return <AppScreen navigation={props.navigation} />;
};
const MyApp = DrawerNavigator( {
  Home: { screen: AppNative },
  Register: { screen: Register },
});
AppRegistry.registerComponent("AppNative", () => MyApp);

您正试图在
RegisterNav
内导航,但导航方法属于您的
MyApp
导航器

如果您在同一个导航器中声明所有屏幕,那么它应该可以工作

const MyApp = DrawerNavigator( {
  Home: { screen: AppNative },
  Register: { screen: Register },
  OtherScreen: { screen: OtherScreen },
});

我需要在有我的注册表的js上声明我的所有屏幕吗?我应该只为所有应用程序使用navigator吗?不一定,你也可以使用嵌套的navigator(),如果你想从navigator外部导航,别忘了传递
导航
道具
不确定它是否与抽屉导航器一起工作,本文档仅介绍包含TabNavigator的StackNavigator
class Register extends Component {
  constructor(props) {
    super(props);
  }
  render() {
    const { navigate } = this.props.navigation;
    //??????
    const RegisterNav = DrawerNavigator({
      Register: { screen: Register },
      OtherScreen: { screen: OtherScreen },
    });
    return (
        <View>
            //??????
            <Button onPress={() => navigate("OtherScreen")}>
            Entrar
            </Button>
        </View>
        );
    }
}
export default Register;
"dependencies": {
    "apsl-react-native-button": "^3.1.0",
    "react": "16.0.0-alpha.12",
    "react-native": "^0.48.2",
    "react-native-maps": "^0.16.2",
    "react-navigation": "^1.0.0-beta.11"
},
const MyApp = DrawerNavigator( {
  Home: { screen: AppNative },
  Register: { screen: Register },
  OtherScreen: { screen: OtherScreen },
});