'use strict';
import React, { Component } from 'react';
import {
AppRegistry,
ScrollView,
StyleSheet,
Text,
View,
TouchableHighlight,
Navigator,
} from 'react-native'; class NavButton extends React.Component{
render(){
return(
<TouchableHighlight style={styles.button}
underlayColor='#b5b5b5' onPress={this.props.onPress}>
<Text style={styles.text}>{this.props.text}</Text>
</TouchableHighlight>
);
} }
class NavMenu extends React.Component{
render(){
return(
<View style={{flex:1,}}>
<Text style={styles.messageText}>{this.props.message}</Text>
<NavButton onPress={()=>{this.props.navigator.push({
message:'Push进来的页面',
sceneConfig:Navigator.SceneConfigs.FloatFromRight,
});}} text='Push到下一级页面' /> <NavButton onPress={() => {
this.props.navigator.push({
message: 'Present进来的页面',
sceneConfig: Navigator.SceneConfigs.FloatFromBottom,
});
}}
text="Present到下一级页面"
/>
<NavButton onPress={() => {
this.props.navigator.pop();
}}
text="Pop到上一级页面"
/>
<NavButton onPress={() => {
this.props.navigator.popToTop();
}}
text="Pop到主页面"
/>
</View>
);
}
}
class MyProject extends Component { render() {
return (
<Navigator style={styles.container} initialRoute={{message:'主页面',}}
renderScene={(route,navigator)=><NavMenu
message={route.message}
navigator={navigator}
/>} configureScene={(route)=>{
if (route.sceneConfig) {
return route.sceneConfig;
}
return Navigator.SceneConfigs.FloatFromBottom;
}}/>
);
} } const styles = StyleSheet.create({
container: {
flex: 1,
},
messageText: {
fontSize: 14,
fontWeight: '500',
padding: 15,
marginTop: 50,
marginLeft: 15,
},
button: {
backgroundColor: 'green',
padding: 15,
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: 'black',
},
text:{
fontSize:14,
color:'white',
},
}); AppRegistry.registerComponent('MyProject', () => MyProject);

效果图:

参考案例:

http://www.lcode.org/%E3%80%90react-native%E5%BC%80%E5%8F%91%E3%80%91react-native%E6%8E%A7%E4%BB%B6%E4%B9%8Bnavigator%E7%BB%84%E4%BB%B6%E8%AF%A6%E8%A7%A3%E4%BB%A5%E5%8F%8A%E5%AE%9E%E4%BE%8B23/

reactnative(2) - Navigator 使用案例的更多相关文章

  1. React-Native 之 Navigator与NavigatorIOS使用

    前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...

  2. reactnative(1) - RefreshControl 使用案例

    'use strict'; import React, { Component } from 'react'; import { AppRegistry, ScrollView, StyleSheet ...

  3. ReactNative Navigator

    https://facebook.github.io/react-native/docs/navigator.html Navigator实现了页面之间的跳转. Demo描述:打开即进入“课程”页面, ...

  4. ReactNative: 使用导航栏组件-NavigatorIOS组件和Navigator组件

    一.简言 在软件开发中,不论是Web还是App,它们的应用程序都是由很多的功能视图组成的.对于这些组合的视图,如何实现页面间平滑地过渡,应用都有统一的一套跳转机制,这个功能就是路由或者叫导航.应用程序 ...

  5. react-native 完整实现登录功能

    react native实现登录功能,包括ui的封装.网络请求的封装.导航器的实现.点击事件. demo下载:react-native 完整实现登录功能 后台如果是springmvc实现的需要配置上如 ...

  6. react native的Navigator组件示例

    import React, {Component} from 'react';import {ScrollView, StyleSheet, Text, View, PixelRatio} from ...

  7. 混合开发的大趋势之一React Native之页面跳转

    转载请注明出处:王亟亟的大牛之路 最近事情有点多,没有长时间地连贯学习,文章也停了一个多礼拜,愧疚,有时间还是继续学习,继续写! 还是先安利:https://github.com/ddwhan0123 ...

  8. React Native中的DeviceEventEmitter.addListener与DeviceEventEmitter.emit

    官方文档没有对这两个方法做很好的解释,需要自己找资料研究.看了几篇文章,总结是和订阅发布模式差不多,用来事件监听发送的. React Native学习之DeviceEventEmitter传值   R ...

  9. 【水滴石穿】github_popular

    项目不难,就是文件摆放位置跟别的不一样 https://github.com/chenji336/github_popular //定义入口是app.js ///** @format */ impor ...

随机推荐

  1. Java基础学习总结(80)——Java性能优化详解

    让Java应用程序运行是一回事,但让他们跑得快就是另外一回事了.在面对对象的环境中,性能问题就像来势凶猛的野兽.但JVM的复杂性将性能调整的复杂程度增加了一个级别.这里Refcard涵盖了JVM in ...

  2. nyoj 55 懒省事的小明(priority_queue优先队列)

    懒省事的小明 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述       小明很想吃果子,正好果园果子熟了.在果园里,小明已经将所有的果子打了下来,而且按果子的不同种 ...

  3. MongoDB怎么快速的删除数据库数据?

    我的mongodb里有10+数据库.现在需要重置这个环境,得到干净的没有数据的MongoDB.怎么快速安全的删除这些数据库数据呢? 记得首先备份你的数据库mongodump -o bakfolder ...

  4. 选择数字(codevs 3327)

    题目描述 Description 给定一行n个非负整数a[1]..a[n].现在你可以选择其中若干个数,但不能有超过k个连续的数字被选择.你的任务是使得选出的数字的和最大. 输入描述 Input De ...

  5. zoj——3624 Count Path Pair

    Count Path Pair Time Limit: 3 Seconds      Memory Limit: 65536 KB You are given four positive intege ...

  6. Ubuntu 16.04安装FTP客户端filezilla

    1.安装: sudo apt-get install filezilla 参考: http://os.51cto.com/art/201103/247564.htm

  7. CentOS设置程序开机启动程序/服务的方法(转)

    注意:CentOS 6下基本没什么问题,CentOS 7估计不一定能行. 在CentOS系统下,主要有两种方法设置自己安装的程序开机启动. 1.把启动程序的命令添加到/etc/rc.d/rc.loca ...

  8. 30、Java并发性和多线程-阿姆达尔定律

    以下内容转自http://ifeve.com/amdahls-law/: 阿姆达尔定律可以用来计算处理器平行运算之后效率提升的能力.阿姆达尔定律因Gene Amdal 在1967年提出这个定律而得名. ...

  9. TI C66x DSP 系统events及其应用 - 5.11(中断控制寄存器)

    C66x DSP运行中断的简要流程: 1.使能了全局中断和子中断.假设硬件检測到中断发生,那么CPU就要跳转. 2.软件把CPU内部的A,B类寄存器的值等推入堆栈保存,把当前PC寄存器的值放入IRP寄 ...

  10. xcode执行后没看到输出的解决的方法

    今天刚在虚拟机中的mac苹果里安装xcode.然后開始看Objective-C. 安装完后由于有默认的代码输出Hello world! ,所以就尝试执行了一发: 可惜没看到输出在哪,尼玛.还以为刚開始 ...