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端收 ...
随机推荐
- CSS3新特性介绍
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...
- vue整理
安装 vue ui axios import axios from 'axios' // let curWwwPath = window.document.location.href // let p ...
- C++标准模板库(STL)之Stack
1.Stack的常用用法 stack:栈,一个后进先出的容器. 1.1.stack的定义 加上头文件#include<stack>和using namespace std; stack&l ...
- 老男孩Python九期全栈学习笔记3
day3 1.上周五内容回顾 格式化输出:%s %d %%:输出% 编码: ASCII码只能显示英文.数字和特殊字符. Unicode:万国码,最开始使用16位表示一个字符,中文不够,后来使用4个字节 ...
- mysql5.7 for windows二进制安装及配置
1)mysql5.7二进制软件下载 下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads 下载软件:mysql-5.7.25-wi ...
- Vue项目本地run与build后样式不同,build后样式不生效
今天老大,让我改一个按钮的样式,就是鼠标放在按钮上,改变字体的颜色.觉得小意思啦,不就是:hover吗? 啊...什么鬼?本地run可以,但是build之后并没有生效!!! 我们项目引入的第三方UI库 ...
- 【转】使用iTextSharp在Asp.Net中操作PDF
使用iTextSharp在Asp.Net中操作PDF操作 使用iTextSharp在Asp.Net中操作PDF系列文章目录 实战 iTextSharp iTextSharp 合并多个PDF文件 C#生 ...
- 一般处理程序、Ajax多图片上传带进度条
<!DOCTYPE html><html><head> <meta charset="utf-8" /> <tit ...
- python学习------迭代器协议和生成器
一.递归和迭代 递归:自己调用自己 举例解释:问路 A问B康明网络科技怎么走,B说我不是很清楚,我帮你问问C,C说我也不知道.我问问D,D说 就在兴隆.之后D返回结果给C,C返回结果给B,B返回结 ...
- JsonP的实现原理?
动态创建script标签,通过script标签中的src跨域属性,连接对方接口,并将回调函数通过接口传递给对方,对方服务器在准备好数据后再通过调用回调函数并以传递参数的方式将数据返回来.