Dmi*_*nik 2 react-native-navigation react-native-navigation-v2
我目前正在尝试从V1升级到react-native-navigation V2,并试图找到一种方法来切换顶部栏按钮按下的侧面菜单.
我的应用程序开始
Navigation.setRoot({
root: {
sideMenu: {
left: {
component: {
name: 'testApp.SideDrawer',
passProps: {
text: 'This is a left side menu screen'
}
}
},
center: {
bottomTabs: {
...
}
},
},
},
});
Run Code Online (Sandbox Code Playgroud)
有没有办法在当前版本中执行此操作?
原来你不能在V2中使用this.props.navigator.toggleDrawer,而应该使用Navigator.mergeOptions来改变抽屉可见性.就我而言:
1)首先为抽屉分配一个Id(id:leftSideDrawer)
Navigation.setRoot({
root: {
sideMenu: {
left: {
component: {
name: 'testApp.SideDrawer',
id: 'leftSideDrawer'
}
},
center: {
bottomTabs: {
...
}
},
},
},
});
Run Code Online (Sandbox Code Playgroud)
2)用它来改变抽屉的可见度
Navigation.mergeOptions('leftSideDrawer', {
sideMenu: {
left: {
visible: true
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3671 次 |
| 最近记录: |