React-native-navigation(wix)如何跳过路由

时间:2018-05-17 06:00:53

标签: ios react-native react-native-navigation

我有3个屏幕

ScreenA, ScreenB, ScreenC

路线

  1. ScreenA-> ScreenB,ScreenB-back-> ScreenA
  2. ScreenA-> ScreenC,ScreenC-back-> ScreenA
  3. ScreenA-> ScreenB-> ScreenC
  4. 我的问题是关于第3条路线,当用户在ScreenC上并且他/她按下backbutton / backnavbarbutton时将显示ScreenA而不是Screen B

    环境

    React Native Navigation version :1.1.431

    React Native version :0.54.4

    平台(iOS,Android或两者兼有?):iOS

1 个答案:

答案 0 :(得分:0)

您可以使用setOnNavigatorEventaddOnNavigatorEvent替换现有导航器来自定义处理后退按钮。 所以在你的构造函数

class ScreenC extends Component {
  constructor(props) {
    super(props);
    this.props.navigator.setOnNavigatorEvent(
      this.onNavigatorEvent.bind(this)
    );
  }

  ...

  onNavigatorEvent(event) {
    switch (event.id) {
      case 'backPress':
        ... what ever you want

    }
  }

  ... rest of your code
}

您可以详细了解here