import React, {Component} from 'react';
import {ScrollView, StyleSheet, Text, View, PixelRatio} from 'react-native';
import { Navigator } from 'react-native-deprecated-custom-components'; // 0.45以上的版本要从这个模块获取导航 export default class NavigatorList extends Component {
render() {
let defaultName = 'List2' // 定义默认的组件名称
let defaultComponent = List2 //定义默认显示的组件
return (
<Navigator
initialRoute={{ name: defaultName, component: defaultComponent}} //初始化路由,有name和component属性,即默认显示的组件信息
// 配置场景
configureScene = {
(route) => {
// 这个是页面之间跳转的动画,VerticalDownSwipeJump是一种动画方式
return Navigator.SceneConfigs.VerticalDownSwipeJump;
}
}
// 将组件显示出来
renderScene={
(route, navigator) => {
let Component = route.component;
return <Component {...route.params} navigator={navigator}/>
}
}
/>
);
}
}
class List2 extends Component {
constructor(props) {
super (props);
this.state = {};
}
_pressButton() {
const {navigator} = this.props;
if(navigator) {
navigator.push({
name: 'Detail',
component: Detail,
})
}
}
render() {
return (
<View style={{flex: 1, backgroundColor: 'red'}}>
<Text onPress={this._pressButton.bind(this)}>内容1</Text>
<Text onPress={this._pressButton.bind(this)}>内容2</Text>
<Text onPress={this._pressButton.bind(this)}>内容3</Text>
</View>
)
}
}
class Detail extends Component {
constructor(props) {
super (props);
this.state = {};
}
_pressButton() {
const {navigator} = this.props;
if(navigator) {
navigator.pop(); //将路由弹出去
}
}
render() {
return (
<ScrollView>
<Text onPress={this._pressButton.bind(this)}>点我跳回去</Text>
</ScrollView>
)
}
}

最新文章

  1. jsonp的三种跨域方式
  2. BZOJ 3437: 小P的牧场 斜率优化DP
  3. hdu 3590 PP and QQ
  4. Android实现网络多线程文件下载
  5. 【CLR】奇妙的String
  6. delphi 为应用程序添加提示
  7. 【转载】Linux小白福利:《超容易的Linux系统管理入门书》(三)在虚拟机上安装Linux
  8. [PeterDLax著泛函分析习题参考解答]第1章 线性空间
  9. ArcGIS 在地图上添加标注
  10. 【剑指offer】面试题35:第一个只出现一次的字符
  11. activity的生命周期详解
  12. Natas Wargame Level20 Writeup(会话状态注入/篡改)
  13. Object类----toString,equals,hashcode
  14. LeetCode之“树”:Balanced Binary Tree
  15. Floyed-Warshall【弗洛伊德算法】
  16. nginx 代理 https 后,应用变成 http
  17. IntelliJ IDEA 注册码 (秘钥)
  18. Spring Boot(Spring的自动整合框架)
  19. scrapy中css选择器初识
  20. “AS3.0高级动画编程”学习:第三章等角投影(上)

热门文章

  1. IOS 文件夹结构
  2. 腾讯云服务器申请免费SSL证书,实现Https。
  3. shapes
  4. volley get post json imagerequest imageloader networkimageview 加载网络本地图片
  5. Python序列——列表
  6. Linux ARM交叉编译工具链制作过程【转】
  7. hdu1198 Farm Irrigation —— dfs or 并查集
  8. ansible 文件模块,很实用
  9. 2016.4.23浙江省赛(zoj3936 zoj3938 zoj3940 zoj3944 zoj3946 zoj3947 )
  10. CodeForces - div1 -650D:Zip-line(主席树 占位)