react-native-navigation侧面菜单

时间:2018-12-09 21:11:59

标签: react-native react-native-navigation drawer side-menu

我正在尝试使用库react-native-navigation v2,我需要一些帮助,我无法使用侧边菜单,我无法使其正常工作...

我这样初始化布局:

Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
    root: {
        sideMenu: {
            id: "sideMenu",
            left: {
                component: {
                    id: "Drawer",
                    name: "navigation.Drawer"
                }
            },
            center: {
                stack: {
                    id: "AppRoot",
                    children: [
                        {
                            component: {
                                id: "App",
                                name: "navigation.AppScreen"
                            }
                        }
                    ]
                }
            }
        }
    }
});

});

使用之前注册的组件,并且在“抽屉”组件中,我希望当用户单击该项目时,它将触发goToScreen2(),

我尝试过: Navigation.setStackRoot(this.props.componentId, {...} Navigation.mergeOptions(this.props.componentId, {...} Navigation.push(this.props.componentId, {...}

但是,没有一个...有人可以解释我如何使其正常工作?

谢谢。

1 个答案:

答案 0 :(得分:0)

您应该从根堆栈中心的侧边菜单中添加要导航到的所有组件,如下所示:

center: {
   stack: {
    id: "AppRoot",
    children: [{
        component: {
        id: "anyID",
        name: "Screen2"
        }
    }]
  }
}