Sen*_*dru 2 react-native react-native-android react-navigation react-navigation-drawer
我正在开发一个使用侧抽屉的 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);
Run Code Online (Sandbox Code Playgroud)
使用的 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)
Run Code Online (Sandbox Code Playgroud)
(也试过key: null)
任何帮助深表感谢!
Har*_*eno 11
尝试阅读https://reactnavigation.org/docs/en/navigating.html#navigate-to-a-route-multiple-times
您需要使用 navigation.push() 来运行具有不同参数的组件副本。
| 归档时间: |
|
| 查看次数: |
4837 次 |
| 最近记录: |