react-navigation:如何在多个屏幕中包装navigationOptions

时间:2018-12-20 08:01:31

标签: javascript react-native react-navigation

我只是想知道是否必须在所有屏幕上放置navigationOptions。像这样:

const AppStackNavigator = createStackNavigator({
  welcome: {
  screen: WelcomeScreen,
  navigationOptions: {
      header: null
    },
  },
  email: {
  screen: EmailLoginScreen,
  navigationOptions: {
      header: null
    },
  },
  password: {
  screen: FindPassWordScreen,
  navigationOptions: {
      header: null
    },
  },
  register: {
  screen: RegisterScreen,
  navigationOptions: {
      header: null
    },
  },
  agree: {
  screen: AgreementScreen,
  navigationOptions: {
      header: null
    }
  }
  })

我可以将navigationOptions包装到所有屏幕吗?但这会给我带来错误。

const AppStackNavigator = createStackNavigator({
  welcome: WelcomeScreen,
  email:EmailLoginScreen,
  password:FindPassWordScreen,
  register: RegisterScreen,
  agree: AgreementScreen,
  navigationOptions: {
      header: null
    },
})

1 个答案:

答案 0 :(得分:0)

是的,可以将设置应用于所有路线,您只是做错了

在这里

const AppStackNavigator = createStackNavigator({
  welcome: WelcomeScreen,
  email:EmailLoginScreen,
  password:FindPassWordScreen,
  register: RegisterScreen,
  agree: AgreementScreen,
},{
    navigationOptions: {
      header: null
    }
})