React native中DrawerNavigator,StackNavigator,TabNavigator导航栏使用
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导航栏使用的更多相关文章
- React Native(四)——顶部以及底部导航栏实现方式
效果图: 一步一步慢慢来: 其实刚入手做app的时候,就应该做出简单的顶部以及底部导航栏.无奈又在忙其他事情,导致这些现在才整理出来. 1.顶部导航栏:react-native-scrollable- ...
- React Native 的组件之底部导航栏 TabBarIOS(一)
import React,{Component}from 'react'; import { AppRegistry, StyleSheet, Text, View, TabBarIOS, } fro ...
- react native 中的ListView
ListView 的运用: 1.首先在react native中引入这个组件: 2.初始化的ListView 的相关属性: constructor(props) { super(props); con ...
- React Native 中 CSS 的使用
首先声明,此文原作者为黎 跃春 React Native中CSS 内联样式 对象样式 使用Stylesheet.Create 样式拼接 导出样式对象 下面的代码是index.ios.js中的代码: / ...
- react native中的欢迎页(解决首加载白屏)
参照网页: http://blog.csdn.net/fengyuzhengfan/article/details/52712829 首先是在原生中写一些方法,然后通过react native中js去 ...
- React Native中的网络请求fetch和简单封装
React Native中的网络请求fetch使用方法最为简单,但却可以实现大多数的网络请求,需要了解更多的可以访问: https://segmentfault.com/a/1190000003810 ...
- [转] 「指尖上的魔法」 - 谈谈 React Native 中的手势
http://gold.xitu.io/entry/55fa202960b28497519db23f React-Native是一款由Facebook开发并开源的框架,主要卖点是使用JavaScrip ...
- [转] 在React Native中使用ART
http://bbs.reactnative.cn/topic/306/%E5%9C%A8react-native%E4%B8%AD%E4%BD%BF%E7%94%A8art 前半个月捣腾了一下Rea ...
- react native中使用echarts
开发平台:mac pro node版本:v8.11.2 npm版本:6.4.1 react-native版本:0.57.8 native-echarts版本:^0.5.0 目标平台:android端收 ...
随机推荐
- 51nod-1627 瞬间移动(组合数+逆元)
题目描述: 有一个无限大的矩形,初始时你在左上角(即第一行第一列),每次你都可以选择一个右下方格子,并瞬移过去(如从下图中的红色格子能直接瞬移到蓝色格子),求到第n行第m列的格子有几种方案,答案对10 ...
- samba及其基本应用
Samba 137/udp,138/udp,139/tcp,445/tcp windowns主机共享: linux主机进行访问查看资源:smbclient -L Server_IP -U 用户名 li ...
- IntelliJ IDEA2018.3 最新破解方法
IntelliJ IDEA2018.3 最新破解方法 输入 http://idea.java.sx/ 即可,亲测可用.如果资金允许还是希望大家能支持正版,尊重原创 ------------- ...
- go生成不重复的纯数字6位的随机数
最近在学go, 按照入门指南学完go的基础语法, 开始学习go的标准库; 借用生成这个小任务复习一下go的基础语法. 推荐go编辑, jb公司的goland, 超级好用. 推荐go入门指南, htt ...
- day 11 装饰器
1.day 10 内容复习 # 之前做得的题 以后再遇到能保证会 # 下周二考 :所有的知识 # 面试题:认真对待 # # 三元运算符 # 接收结果的变量 = 条件为真的结果 if 条件 else 条 ...
- 使用本机IP调试web项目
1.查看本机IP 使用命令行查看本机ip地址: cmd 进入命令行 Ipconfig 查询本机ip. 2.找到启动项目的配置文件 启动IIS查找配置文件的位置 点击显示所有应用程序 3.修改项 ...
- ROS机器人导航仿真(kinetic版本)
准备工作: ubuntu 16.04系统;ROS kinetic版本;ROS包turtlebot,导航包rbx1,模拟器arbotix,可视化rviz 1.安装ubuntu 16.04系统与安装ROS ...
- 设计模式-builder(构造器模式)
好处: 多个属性时,可以清楚明了知道属性, 重叠构造起器的安全性和JavaBeans模式的可读性 只需要制定需要建造的类型就可以得到他们 实例: public class NutritionFacts ...
- VM虚拟机拍摄快照时出错或者克隆失败解决办法
在换了固态硬盘后,下载好VM,装虚拟机,结果克隆虚拟机和拍摄快照时出问题了. 拍摄快照时出错或者隆失败出现参数错误如图: 所提供的参数中有一个无效参数 解决办法 出现这个问题一般是在机械硬盘的电脑上面 ...
- JAVA同步锁机制 wait() notify() notifyAll()
wait() notify() notifyAll() 这3个方法用于协调多个线程对共享数据的存取,所以必须在synchronized语句块中使用. wait() 必须在synchronized函数或 ...