【问题标题】:React Native: react-native-router-flux type Property issueReact Native:react-native-router-flux 类型属性问题
【发布时间】:2018-10-03 08:54:39
【问题描述】:

我正在使用 react-native-router-flux react native 库进行导航,但 type 属性不起作用

<Route name="error" component={Error} title="Error"  type="reset"/>

它会给出类似的错误

_this2[type] is not a function.

react-native-router-flux 版本 4.0.0-beta.28

【问题讨论】:

  • 设置type="push"是否有效?
  • 不,它也不起作用

标签: react-native react-native-router-flux


【解决方案1】:

问题是类型应该用在&lt;Scene&gt;而不是&lt;Route&gt;

这里是工作示例

import { Router, Scene, Actions } from 'react-native-router-flux';
<Router>
      <Scene key="root">
        <Scene key="login" component={LoginForm} hideNavBar={'true'} initial={true} />
        <Scene key="signin" component={SigninForm} />
        <Scene
          type="reset"
          key="dashboard"
          component={NavigationView}
          initial={props.isLogin}
          hideNavBar={'true'}
        />
      </Scene>
    </Router>

还有其他方法: 从场景中移除类型并在移动到其他屏幕时将其用作参数。

Actions.error({ type:'reset' });
or
Actions.reset('KEY'); // this one is work, i just tested now. 

或者你可以replace 看到这个 https://github.com/aksonov/react-native-router-flux/issues/467

【讨论】:

  • 我试过这个,但它不起作用,它给出了同样的错误。
  • @Priya 提及您的库版本。并像我一样添加完整的代码。这将有助于理解流程
【解决方案2】:

你可以传递js文件为

<Router hideNavBar={true}>
            <Stack key="root" hideNavBar={true}>
                <Scene key="splashscreen" component={SplashScreen} title="SplashScreen" initial={true}></Scene>

            </Stack>
        </Router>

无论你想去哪一页都可以通过 Actions.splashscreen() (需要通过场景中写的key)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多