'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. HDU 1253 三维数组的图上找最短路

    题目大意: 从三维空间的(0,0,0)出发到(a-1,b-1,c-1),每移动一个都要时间加一,计算最短时间 根据六个方向,开个bfs,像spfa那样计算最短路径就行了,但是要1200多ms,也不知道 ...

  2. FZU 2105 (线段树)

     Problem 2105 Digits Count  Problem Description Given N integers A={A[0],A[1],...,A[N-1]}. Here we h ...

  3. [poj2975]Nim_博弈论

    Nim poj-2975 题目大意:给定n堆石子,问:多少堆石子满足操作之后先手必胜. 注释:$1\le n\le 10^3$. 想法: 我们设M=sg(x1)^sg(x2)^...^sg(xn).其 ...

  4. LVS 源代码分析

    http://blog.chinaunix.net/uid/11207493.html http://zh.linuxvirtualserver.org/blog/3309

  5. [转]C++回调函数(callback)的使用

    原文地址:http://blog.sina.com.cn/s/blog_6568e7880100p77y.html 什么是回调函数(callback)    模块A有一个函数foo,他向模块B传递fo ...

  6. wikioi 1029 中序遍历总数

    题意:给出前序遍历和后序遍历,求总共同拥有多少种中序遍历的可能. 思路: 对于一个节点.当且仅当它仅有一棵子树时,在保证先序和后序同样的前提下,才可能有不同的中序(它的子树可在左或右,所以有2种): ...

  7. 在net中json序列化与反序列化 面向对象六大原则 (第一篇) 一步一步带你了解linq to Object 10分钟浅谈泛型协变与逆变

    在net中json序列化与反序列化   准备好饮料,我们一起来玩玩JSON,什么是Json:一种数据表示形式,JSON:JavaScript Object Notation对象表示法 Json语法规则 ...

  8. UVA 10555 - Dead Fraction(数论+无限循环小数)

    UVA 10555 - Dead Fraction 题目链接 题意:给定一个循环小数,不确定循环节,求出该小数用分数表示,而且分母最小的情况 思路:推个小公式 一个小数0.aaaaabbb... 表示 ...

  9. IOS 数据存储之 Core Data具体解释

    Core Date是ios3.0后引入的数据持久化解决方式,它是是苹果官方推荐使用的.不须要借助第三方框架.Core Date实际上是对SQLite的封装.提供了更高级的持久化方式.在对数据库操作时, ...

  10. bootstrap table load数据

    直接load数据: $("#button").click(function(){ var name=$("input[name='name']").val(); ...