React-Native 中 react-navigation 简单
来源:互联网 发布:微博个性域名二次修改 编辑:程序博客网 时间:2024/05/25 05:34
1. 其详细的内容可以参照 http://blog.csdn.net/u013718120/article/details/72357698
2.导航栏的简单方法
3.创建两个js文件,第一个是开始界面(AllMine.js),跳转到的界面(Demo.js)
3.1 AllMine.js
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */import React, { Component } from 'react';import { AppRegistry, StyleSheet, Text, View, Button,} from 'react-native';//导入包import { StackNavigator } from 'react-navigation';var Home = require('../Home/AllHome');var Demo = require('../Home/Demo');var Mine = React.createClass({ render() { //默认的方法调用 const { navigate } = this.props.navigation; return ( <View style={styles.container}> <Text style={styles.welcome}> 我的 </Text> {/* 点击以后跳转,{name: 'Lucy'} 传的数据 */} <Button onPress={() => this.props.navigation.navigate('Profile', {name: 'Lucy'})} title="Go" /> </View> ); },});/** * 设置其属性 */const SimpleApp = StackNavigator( { //这个是开始页面 Home: { screen: Mine }, //跳转的地方 Profile: { path: 'people/:name', screen: Demo, }, }, { navigationOptions:{ headerBackTitle:null, headerTintColor:'#333333', showIcon:true, swipeEnabled:false, animationEnabled:false, title : '我的', }, mode:'card', });const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, },});module.exports = SimpleApp;
3.2 Demo.js
import React, { Component } from 'react';import { AppRegistry, StyleSheet, Text, View} from 'react-native';import { StackNavigator } from 'react-navigation';var Demo = React.createClass({ render() { return ( <View style={styles.container}> <Text style={styles.welcome}> {/* 上个界面传过的数据*/} {this.props.navigation.state.params.name} </Text> </View> ); }});const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, },});module.exports = Demo;
阅读全文
0 0
- React-Native 中 react-navigation 简单
- React Native --react-navigation
- React Native react-navigation
- react-native 学习 ----- React Navigation
- React-Native中导航组件react-navigation的使用
- 【React Native开发】- React Navigation的使用
- React Native导航react-navigation经验浅谈
- react-native结合react-navigation之TabNavigator
- 【React Native】react-Navigation之StackNavigator
- react-navigation 简单使用
- React-native Navigation之TabNavigator
- react-native Navigation使用一
- (三)React Native中Navigation组件的快速入门
- React Native中ListView的简单使用
- React-Native简单介绍
- react-Native-Experimental-Navigation-with-redux(一)
- react-native-navigation-drawer的使用
- react-native navigation的学习与使用
- Grid Layout Group 后添加的放在最左边
- TCP选项之TCP_CORK和TCP_NODELAY的作用和意义
- 2017-7-19
- 骚骚的STL学习笔记
- Shiro框架编码/解码(五)
- React-Native 中 react-navigation 简单
- 用xampp链接mysql出现的问题
- Datasture-1 Stack--用Java实现
- HPU 一只小蜜蜂
- Python 标准库学习之argparse
- lombok(转载)
- Unknown class AvatarView in Interface Builder file.
- 手机号正则表达式
- Python selenium中一定要会用selenium等待的三种等待方式解读