import React from 'react';
import { View, Text,Button } from 'react-native';
import { DrawerNavigator,StackNavigator,TabNavigator } from 'react-navigation';
/*
* 主屏幕,可以跳转至Tab Navigator和DrawerNavigator*/
const HomeScreen = ({ navigation }) => (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Home Screen</Text>
<Button
onPress={() => navigation.navigate('Details1')}
title="Go to details1"
/>
<Button
onPress={() => navigation.navigate('Details2')}
title="Go to details2"
/>
</View>
);
/*次屏幕一
* 用于承接TabNavigator
* */
const DetailsScreen1 = () => (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Details1 Screen</Text>
</View>
);
/*
* 次屏幕二
* 用于承接DrawerNavigator
* */
const DetailsScreen2 = () => (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Details2 Screen</Text>
</View>
);
/*
* TabNavigator主屏幕
* */
const HoScreen = () => (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Ho Screen</Text>
</View>
);
/*
* TabNavigator次屏幕
* */
const ProfileScreen = () => (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Profile Screen</Text>
</View>
);
/*TabNavigator
* */
const RootTabs = TabNavigator({
Ho: {
screen: HoScreen,
},
Profile: {
screen: ProfileScreen,
},
});
/*
* DrawerNavigator主屏幕
* */
const HScreen = ({navigation}) => (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>H Screen</Text>
<Button
onPress={() => navigation.navigate('DrawerToggle')}
title="Open Drawer"
/>
</View>
);
/*
* DrawerNaivigator
* 次屏幕
* */
const ProScreen = () => (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Pro Screen</Text>
</View>
);
/*
* DrawerNavigator
* */
const RootDrawer = DrawerNavigator({
H: {
screen: HScreen,
},
Pro: {
screen: ProScreen,
},
});
/*
*
* StackNavigator
* */
const RootNavigator = StackNavigator({
Home: {
screen: HomeScreen,
navigationOptions: {
headerTitle: 'Home',
headerRight: <Button title="Info" />,
},
},
Details1: {
screen: RootTabs,
navigationOptions: {
headerTitle: 'Details1',
},
},
Details2: {
screen: RootDrawer,
navigationOptions: {
headerTitle: 'Details2',
},
},
});
export default class App extends React.Component {
render() {
return <RootNavigator/>;
}
}

 效果图

 

React native中DrawerNavigator,StackNavigator,TabNavigator导航栏使用的更多相关文章

  1. React Native(四)——顶部以及底部导航栏实现方式

    效果图: 一步一步慢慢来: 其实刚入手做app的时候,就应该做出简单的顶部以及底部导航栏.无奈又在忙其他事情,导致这些现在才整理出来. 1.顶部导航栏:react-native-scrollable- ...

  2. React Native 的组件之底部导航栏 TabBarIOS(一)

    import React,{Component}from 'react'; import { AppRegistry, StyleSheet, Text, View, TabBarIOS, } fro ...

  3. react native 中的ListView

    ListView 的运用: 1.首先在react native中引入这个组件: 2.初始化的ListView 的相关属性: constructor(props) { super(props); con ...

  4. React Native 中 CSS 的使用

    首先声明,此文原作者为黎 跃春 React Native中CSS 内联样式 对象样式 使用Stylesheet.Create 样式拼接 导出样式对象 下面的代码是index.ios.js中的代码: / ...

  5. react native中的欢迎页(解决首加载白屏)

    参照网页: http://blog.csdn.net/fengyuzhengfan/article/details/52712829 首先是在原生中写一些方法,然后通过react native中js去 ...

  6. React Native中的网络请求fetch和简单封装

    React Native中的网络请求fetch使用方法最为简单,但却可以实现大多数的网络请求,需要了解更多的可以访问: https://segmentfault.com/a/1190000003810 ...

  7. [转] 「指尖上的魔法」 - 谈谈 React Native 中的手势

    http://gold.xitu.io/entry/55fa202960b28497519db23f React-Native是一款由Facebook开发并开源的框架,主要卖点是使用JavaScrip ...

  8. [转] 在React Native中使用ART

    http://bbs.reactnative.cn/topic/306/%E5%9C%A8react-native%E4%B8%AD%E4%BD%BF%E7%94%A8art 前半个月捣腾了一下Rea ...

  9. react native中使用echarts

    开发平台:mac pro node版本:v8.11.2 npm版本:6.4.1 react-native版本:0.57.8 native-echarts版本:^0.5.0 目标平台:android端收 ...

随机推荐

  1. 微信小程序 页面跳转方式

    // 保留当前页面,跳转到应用内的某个页面,使用wx.navigateBack可以返回到原页面. // 注意:调用 navigateTo 跳转时,调用该方法的页面会被加入堆栈,但是 redirectT ...

  2. JDK7动态代理源码分析

    IObject proxy = (IObject) Proxy.newProxyInstance(IObject.class.getClassLoader(), new Class[]{IObject ...

  3. this的四种用法

    函数运行时,自动生成的一个内部对象,只能在函数内部使用 随着函数使用场合的不同,this的值也发生着改变,但是有一个总原则:this指的是调用函数的那个对象(核心) 1.纯粹的函数调用 this指的是 ...

  4. element-ui <el-date-picker> 回显格式 yyyy-MM-dd 传值格式 yyyyMMddHHmmss

    <template> <!-- 需求:使用 <el-date-picker> 日期插件 前端显示2018-10-22 后台需要传时间戳,对这个日期插件不熟悉,当时搞了好长 ...

  5. linux常用命令 echo输出命令

    echo输出命令 'echo [选项] [输出内容]' 选项 '-e' 支持反斜线控制的字符转换 控制字符​ \a 输出警告音 \b 退格键,也就是向左删除键 \n 换行符 \r 回车键 \t 制表符 ...

  6. C#UDP广域网,局域网通信-原理分析

    一.UDP局域网通信. 这个比较简单,关于局域网中的2台或者更多的计算机之间的UDP通信,网络上一大把,直接复制粘贴就可以使用,原理也非常简单.所以,本文不做详细介绍. 二.UDP广域通信(包括路由器 ...

  7. WinHex18.4算法分析

    经过分析,注册码分为六个部分: Name: "xxx" Addr1: "yyy" Addr2: "zzz" 这三个字符不代表长度 Key1: ...

  8. es6(二)

    三 . 正则扩展: 1.构造函数的扩展 let regex = new Regex('xyz','i'); let regex2 = new Regex(/xyz/i);//test() 方法用于检测 ...

  9. Oracle数据库TNS错误解决方法

    ORA-12154: TNS:could not resolve the connect identifier specified ,即无法解析指定的连接 标识符.这说明缺少了一个环境变量,TNS_A ...

  10. BPM与OA区别

    核心差异: OA解决的是流程有无问题 BPM解决的是流程更好更优的问题 主要差异如下: 1.BPM有更好的广度跟深度 这里的广度是指应用场景的广度. BPM一般都会以端到端的方式衔接企业运营过程的上下 ...