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端收 ...
随机推荐
- 爬虫(七)图片懒加载技术、selenium和PhantomJS
动态数据加载处理 一.图片懒加载 什么是图片懒加载? 案例分析:抓取站长素材http://sc.chinaz.com/中的图片数据 #!/usr/bin/env python # -*- coding ...
- centos升级openssl方法及步骤
1.下载要升级到的openssl包https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.4p1.tar.gz 2.升级opens ...
- (04) springboot 下的springMVC和jsp和mybatis
1. springboot 和springmvc下的注解完全一样(新增了一些有用的) 常用的注解如下: @Controller @RestController= @Controller + @Resp ...
- JVM常用配置参数说明
堆设置 -Xms256M:初始堆大小256M,默认为物理内存的1/64 -Xmx1024M:最大堆大小1024M,默认为物理内存的1/4,等于与-XX:MaxHeapSize=64M -Xmn64M: ...
- 对redux的粗略理解
redux是一个js库,用于前端应用的状态管理,但是在一个较小的项目中,即一个并不需要太多交互的项目中完全可以不用redux,非要使用的话反而增加了项目的复杂度. 关于redux就是状态与数据一一对应 ...
- javascript 模板
今天想记录下对arttemplate模板的使用,哎,其实这玩意的兴起主要还是得从浏览器操作dom说起.如果修改浏览器的某一个dom节点就会引起文档流的重绘,然后这个重绘的耗时相当的大,是昂贵的开销.所 ...
- week3
___________________________________函数________________________ 返回值 = 0 ,返回 0 返回值 = 1, 返回object 返回值> ...
- Mac中java实现自动打开软件问题
Runtime.getRuntime().exec("/Applications/NetEaseMusic.app/Contents/MacOS/NetEaseMusic");遗留 ...
- 我只想要Linux的IP地址
大家都知道ifconfig 可以查看centos的ip地址,但是我如果只要ip地址该怎么办呢?首先上ifconfig [root@centos ~]# ifconfig eth0 eth0 Link ...
- JAVAEE第三周
2.背景:看到Session时,感到很熟悉,毕竟涉及到过类似的编程,用得最多的地点就是保存客户端的信息和记录,比如说你已经登陆过某个网站,下次访问时不想要麻烦的重新登陆你就就可以使用这个机制.Sess ...