react-native - react-native-navigation 侧边菜单
问题描述
我正在尝试使用库 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"
}
}
]
}
}
}
}
});
});
使用之前注册的组件,并且在 Drawer 组件中,我希望当用户单击该项目时,它将触发 goToScreen2(),
我试过了 :
Navigation.setStackRoot(this.props.componentId, {...}
Navigation.mergeOptions(this.props.componentId, {...}
Navigation.push(this.props.componentId, {...}
但是,没有一个工作......有人可以解释我怎样才能让它工作?
谢谢。
解决方案
您应该添加要从根堆栈中心的侧面菜单导航到的所有组件,如下所示:
center: {
stack: {
id: "AppRoot",
children: [{
component: {
id: "anyID",
name: "Screen2"
}
}]
}
}
推荐阅读
- java - 如何在tomcat中运行使用高内存的很长的请求?
- python-3.x - "s = "0123456789" print(s[2:-1:-1])" 切片运算符的输出
- sql - 如何将文本文件转换为 SQL 插入语句?
- c - 我的程序试图访问什么内存?因为它的段错误
- angular - 在Angular NGXS中访问数组内的嵌套对象
- reactjs - React:HOC组件内部的触发方法
- android - TransformException:DexArchiveBuilderException:无法处理 \.gradle\caches\transforms-1\files-1.1\play-services-xxx-12.0.1.aar\xxx\classes.jar
- c# - 设置布尔值列表的最佳方法
- html - 如何从其他网站导入 CSS 自定义字体
- python - 为什么类方法名的前缀是类名,而不是其他对象?