React Native Android(二)Navigator知识点

知识点:
Navigator 是React-Native原生的,跨平台的导航器组件。Navigator会维护一个路由栈,并提供一系列api帮助开发者完成程序内不同页面之间的跳转及参数传递。
Route 是标识导航器渲染标识每一个页面的对象。

  • getCurrentRoutes() 返回当前的路由栈列表信息。
  • push(route) 将route压入路由栈,跳转到route指定的页面。
  • pop() 弹出路由栈最顶层的路由,放回前一个页面。
  • replace(route) 用传入的route替换当前route,跳转到route指定的页面。
<Navigator style={{flex:1}} configureScene={this._configureScene} renderScene={this._renderScene} initialRoute={{ component:WelcomScene, }} />

configureScene function 用来配置页面跳转的动画,会传入路由和路由栈两个参数,返回一个页面跳转动画配置对象

_configureScene(route,routeStack) {
        return Navigator.SceneConfigs.PushFromRight;
    }

renderScene function 用来渲染每一个路由指定的页面。传入route和navigator两个参数。

_renderScene(route, navigator) {
        let Component = route.component;
        _navigator = navigator;
        return (<Component navigator={navigator} route={route}/>)
    }

initialRoute object 初始路由,导航器首先渲染的路由页面。

源码

你可能感兴趣的:(navigator,react-native)