zoukankan      html  css  js  c++  java
  • react-navigation的跳转(2.5.1版本)

    import {
    createStackNavigator,//注册路由
    createBottomTabNavigator,//注册tabbar
    createDrawerNavigator//注册侧边栏
    } from "react-navigation"
    需要先下载navigation,我的版本是2.5.1版本;
    目前我所知道的是在最新的版本中路由的版本为4.0版本,注册的方式会与2.0版本不同。
    在最新的项目中0.6版本中会有一次更新的写法,rn组件的写法是函数的写法;
    返回的是一个视图层,我所用的版本项目版本是0.57.8,组件的写法是类组件的写法;
    类组件根据路由注册不同的东西,需要定义不同的头部。
    //router
    import Home from "./src/router/home"
    import Detail from "./src/router/detail"

    //tabbar
    import One from "./src/tabBar/one"
    import Two from "./src/tabBar/two"
    import Three from "./src/tabBar/three"

    //路由的设置
    export const Router = createStackNavigator({
    Home:{screen:Home},
    Detail:{screen:Detail},
    })


    // //tabBar的设置
    export const TabBar = createBottomTabNavigator({
    One:{screen:One},
    Two:{screen:Two},
    Three:{screen:Three}
    })


    //侧边栏的设置
    export const Drawer=createDrawerNavigator({
    One:{screen:One},
    Two:{screen:Two},
    Three:{screen:Three}
    },{
    drawerBackgroundColor:"#09ff42",
    useNativeAnimations:true
    })
    根据不同的需求定义不同的组件注册方式;

    打开侧边栏的方式是
    this.props.navigation.openDrawer()
    调用这个方法可以打开侧边栏。
  • 相关阅读:
    图论4-floyd
    。。。
    [LOJ10164]数字游戏
    KMP模板
    无向图割点模板
    tarjan有向图模板
    LCA倍增模板
    P2149 [SDOI2009]Elaxia的路线
    树的直径dp模板
    [暑假集训]Day4 T3 平板涂色
  • 原文地址:https://www.cnblogs.com/jingguorui/p/11475634.html
Copyright © 2011-2022 走看看