react-native-router-flux路由库详解

裴俊智
2023-12-01

react-native-router-flux 是一个基于 react-navigation 路由框架,简化了RN页面跳转的步骤,并且一直随着 react-navigation 升级更新版本。使用react-native-router-flux 框架,可以将全部的页面跳转的处理逻辑都写在一个地方,方便了后续的维护,下面是react-native-router-flux的源码地址:react-native-router-flux

下面先来一个简单的例子,讲解 react-native-router-flux 的最基本使用方法。

import {Router, Scene} from "react-native-router-flux";
import PageOne from "./Component/PageOne"; 
import PageTwo from "./Component/PageTwo";

const Root = () => {
  return (
    <Router>
       <Scene key="root">
        <Scene
          key="one"
          component={PageOne}
          title="PageOne"
          initial={true}
        />
        <Scene key="two" component={PageTwo} title="PageTwo" />

      </Scene>
    </Rout
 类似资料: