将本机路由器通量从子场景反应回初始屏幕

react native router flux back to the initial screen from the sub scene

我正在尝试在个人资料页面上实现 logout 按钮。

我定义了以下路线。

<Router>
    <Scene initial  key='splashScreen' component={SplashScreen} title='Sayan' hideNavBar />
    <Scene key='loginScreen' component={LoginScreen} title='President Login' hideNavBar />
    <Scene key='drawer' component={NavigationDrawer} open={false}>
        <Scene key='drawerChildrenWrapper' hideNavBar>
            <Scene key='homeScreen' component={HomeScreen} title='Sayan' hideNavBar />
            <Scene key='createUserScreen' component={CreateUserScreen} title='Create a user' hideNavBar />   
            <Scene key='Profile' component={ProfileScreen} title='Profile' hideNavBar />
        </Scene>
    </Scene>
</Router>

如果我想返回到 splashScreenloginScreen 场景,logout 按钮处理程序是什么样的?

这应该会关闭当前屏幕并显示登录屏幕: Actions.popTo('loginScreen');

Actions.pop 关闭当前场景。 Actions.popTo 本质上是两个命令...... Actions.pop() 和 Actions.loginScreen()

你可以在下一条路线中使用type="reset"

in my case:

<Scene key="Wellcome"
   component={Wellcome}
   title="Wellcome"
   initial 
/>
<Scene key="Home"
   component={Home}
   title="Home"
   type='reset'
/>