RN中的navigation的使用方式 demo
来源:互联网 发布:谷歌程序员工资 编辑:程序博客网 时间:2024/06/07 05:09
在终端中下载下来相关联的依赖库npm install react-navigation --save 运行时npm install
在终端下载tab使用库 npm install react-native-tab-navigator - -save
导入头 然后看代码
/** index.android.js
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, {Component }from'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Image,
Button
} from'react-native';
import {
StackNavigator
}from'react-navigation';
import ThreeScreenfrom'./Three.js';
class HomeScreenextendsReact.Component {
static navigationOptions= {
title: 'Welcome',
};
render() {
const { navigate }=this.props.navigation;
return (
<View>
<Text>Hello, Chat App!</Text>
<Button
onPress={()=>navigate('Chat')}
title="Chat with Lucy"
/>
</View>
);
}
}
class ChatScreenextendsReact.Component {
static navigationOptions= {
title: 'Chat with Lucy',
};
render() {
const { navigate }=this.props.navigation;
return (
<View>
<Text>Chat with Lucy</Text>
<Button
onPress={()=>navigate('Three')}
title="to to ThreeScreen"
/>
</View>
);
}
}
const SimpleApp=
StackNavigator({
Home: { screen:HomeScreen },
Chat: { screen:ChatScreen },
Three: { screen:ThreeScreen},
});
var styles=StyleSheet.create ({
wrapper: {
height:80,
},
slide: {
height:80,
resizeMode:Image.resizeMode.contain,
},
});
AppRegistry.registerComponent('test', ()=>SimpleApp);
另一个界面中的代码Three.js
import React,{Component}from'react';
import {
AppRegistry,
Text,
View,
Button,
} from'react-native';
class Three extendsReact.Component {
static navigationOptions = {
title: 'Three Sceen',
};
render() {
const { goBack } =
this.props.navigation;
return (
<Button
title="Go back"
onPress={()=>goBack()}
/>
);
}
}
export default Three;//导出Three 让别的导入时可以找到
自己摸索,如果不对,谢谢大家前来留言指导。阅读全文
0 0
- RN中的navigation的使用方式 demo
- RN的listview Demo
- 混合应用使用react-navigation调用起来RN指定的某个界面
- RN-Demo
- 供参考的rn脚手架demo项目
- RN中UIImage的使用
- RN版本UITextFeild的使用
- RN点击事件的使用
- realm在rn中的使用,强力db
- Navigation Drawer的使用
- Android Navigation的使用
- Navigation View的使用
- react-navigation的使用
- Navigation的使用
- RN入门练习Demo
- 个人经常使用的RN学习地址
- RN,webview里onMessage属性的使用
- Navigation View的使用详解
- JS-纯JavaScript代码显示系统当前时间
- 在jsp页面上直接打开pdf文档
- 集群安装流程
- hadoop 伪分布式安装配置
- 下面这个错误怎么解决 大神们帮帮忙 急需
- RN中的navigation的使用方式 demo
- 关于BETA、RC、ALPHA、Release、GA等版本号的意义
- 头文件中的ifndef/define/endif 的作用
- java中对象的排序
- HDU 6194 string string string
- JavaScript验证上传文件大小和类型
- java 不常用关键字
- 将keil中的数据绘成波形
- java 开发微信红包