【发布时间】:2019-06-23 17:00:41
【问题描述】:
我正在开发一个使用侧抽屉的 RN 应用程序。(RN 版本:0.59.8)
const DrawerNavigator = createDrawerNavigator(
{
Home: {
screen: HomeScreen
},
Poems: {
screen: PoemsScreen
},
Contest: {
screen: ContestScreen
},
AboutMe: {
screen: AboutMeScreen
}
},
DrawerConfig
);
export default createAppContainer(DrawerNavigator);
使用的 react-navigation 版本是 3.11.0。 在菜单中,多个子项指向同一个页面,一个 ViewPager,但具有不同的参数(页面索引)。 问题是以下都不起作用:
- 尝试使用推送而不是导航(返回
_this2.props.navigation.push is not a function) - 正在尝试重置相应的堆栈。
const resetAction = StackActions.reset({
index: 0,
key: 'Poems',
actions: [NavigationActions.navigate({ routeName: 'Poems' })]
})
this.props.navigation.dispatch(resetAction)
(也试过key: null)
非常感谢任何帮助!
【问题讨论】:
-
this.props.navigation.navigate('诗歌', { key: 1})
-
@GokulKulkarni 感谢您的洞察力,但它不起作用:(
-
我无法正确理解您的问题,请帮助理解。您想导航到具有不同参数的同一页面吗?
标签: react-native react-native-android react-navigation react-navigation-drawer