当我使用navigationActions.reset时,如何获得参数值



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

相关内容

  • 没有找到相关文章

最新更新