app.js
const DrawerStack = DrawerNavigator({
Dashboard: { screen: Dashboard},
Pdfview: { screen: Pdfview},
screen2: { screen: Screen2 }
})
login.js
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'DrawerStack', params: { foo: 'bar' }
}),
],
});
我尝试在仪表板上获取参数值,但我在仪表板上不确定
dashboard.js
componentWillMount() {
console.info(this.props.navigation.state.params)
}
您应该直接导航到仪表板,而不是Routename中的抽奖
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Dashboard', params: { foo: 'bar' }
}),
],
});
这应该有效。
this.props.navigation.state.params.foo