ReactNative的基本组件的认识
通过官网的react-native init myProject,并打开Android Studio的手机模拟器进行调试
下面的代码使用了 Text 、Image、View、TextInput和的react-native-modal-dropdown(下拉框)的组件,初步开发了一个登陆界面
1、Image的 source静态资源需要 require的引入,服务器资源的引入uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
2、一行显示设置flexDirection: 'row'
3、android的输入框TextInput的
<TextInput
style={{height: 40,width:200,padding: 0}}
underlineColorAndroid="transparent" 去掉下边框
keyboardType ='numeric' 调起的是数字键盘
placeholder="请输入手机号"
onChangeText={(text) => this.setState({text})}
secureTextEntry={true} 像password的输入
/>
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/ import React, {
Component
} from 'react';
import {
Platform,
StyleSheet,
Text,
View,
Image,
TextInput
} from 'react-native'; import ModalDropdown from 'react-native-modal-dropdown'; const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' +
'Cmd+D or shake for dev menu',
android: 'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
}); type Props = {};
export default class App extends Component < Props > {
constructor(props) {
super(props);
this.state = {
text: '',
value:'',
c:'86'
}
}
render() {
let pic = {
uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
};
let phone=[86,100,200,300]
return(
<View style={styles.container}>
<Image source={require('./img/img.jpg')} style={{width: 193, height: 110}} />
<Text style={styles.title}>
代理后台
</Text> <View style={{flexDirection: 'row',borderBottomColor:'#dbdbdb',borderBottomWidth:1}}>
<Text style={{marginRight:10}}>
国家/地区
</Text>
<ModalDropdown
options={['中国大陆', '香港','台湾','美国']}
dropdownStyle={{height: 300,width:200}}
textStyle={{height: 30,width:200,padding:0}}
defaultValue='中国大陆'
onSelect={(index,value)=>{
this.setState({
c:phone[index]
})
}}
/>
</View>
<View style={{flexDirection: 'row',borderBottomColor:'#dbdbdb',borderBottomWidth:1}}>
<Text style={{height: 40,marginRight:40,lineHeight:40}}>
+ {this.state.c}
</Text>
<TextInput
style={{height: 40,width:200,padding: 0}}
underlineColorAndroid="transparent"
keyboardType ='numeric'
placeholder="请输入手机号"
onChangeText={(text) => this.setState({text})}
secureTextEntry={true}
/>
</View>
<View style={{
borderBottomColor:'#dbdbdb',
borderBottomWidth:1
}}>
<TextInput
style={{height: 40,width:200,padding:0}}
keyboardType ='numeric'
underlineColorAndroid="transparent"
placeholder="请输入验证码"
onChangeText={(text) => this.setState({text})}
/>
</View>
<Text style={styles.instructions}>
{this.state.text}
</Text>
<Text style={styles.instructions}>
{instructions}
</Text>
</View>
);
}
} const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'flex-start',
paddingTop: 10,
alignItems: 'center',
backgroundColor: '#fff',
},
title: {
fontSize: 20,
textAlign: 'center',
color: '#000',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
ReactNative的基本组件的认识的更多相关文章
- React-Native之截图组件view-shot的介绍与使用
React-Native之截图组件view-shot的介绍与使用 一,需求分析 1,需要将分享页生成图片,并分享到微信好友与朋友圈. 二,react-native-view-shot介绍 1,可以截取 ...
- react-native 封装 VedioPlayer 组件
1.封装组件 src/components/VideoPlayer/index.js /** * 视频播放器 组件(VideoPlayer) */ import React, {Component} ...
- ReactNative: 使用View组件创建九宫格
一.简言 初学RN,一切皆新.View组件跟我们iOS中UIView类似,作为一个容器视图使用,它主要负责承载其他的子组件.View组件采用的是FlexBox伸缩盒子布局,通过对它的布局可以影响子组件 ...
- [技术博客]React-Native中的组件加载、卸载与setState问题
React-Native中的组件加载.卸载与setState问题. Warning: Can only update a mounted or mounting component. This usu ...
- React-Native新列表组件FlatList和SectionList学习 | | 联动列表实现
React-Native在0.43推出了两款新的列表组件:FlatList(高性能的简单列表组件)和SectionList(高性能的分组列表组件). 从官方上它们都支持常用的以下功能: 完全跨平台. ...
- React-Native 之 常用组件Image使用
前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...
- react-native自定义原生组件
此文已由作者王翔授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 使用react-native的时候能够看到不少函数调用式的组件,像LinkIOS用来呼起url请求 Link ...
- ReactNative: 使用对话框组件AlertIOS组件
一.简介 在使用一款App的时候,经常会用到对话框进行信息的友好提示,一般简单要求性不高的时候我们可以使用web提供的alert实现即可.但是,对于需要交互性和美观性的对话框,alert就明显无法满足 ...
- ReactNative: 使用网页组件WebView组件
一.简介 在移动端开发中,很多时候需要嵌入一个网页来帮助实现某一个活动,这方式大大提高了活动快速迭代的灵活性,在RN中,同样也这么处理这种情况的.其实,这种混合式开发称为Hybird APP,它们就是 ...
随机推荐
- Centos 6.5升级openssh漏洞
CentOS 6.5下openssh升级 在有的企业中每年都会安全扫描,因为实现远程连接比较重要,如果openssh版本过低,就要对其升级,本文主要讲述openssh升级的步骤. openssh升级主 ...
- FMECA分析
FMECA是针对产品所有可能的故障,并根据对故障模式的分析,确定每种故障模式对产品工作的影响,找出单点故障,并按故障模式的严重度及其发生概率确定其危害性.所谓单点故障指的是引起产品故障的,且没有冗余或 ...
- 解决 Cannot find OpenSSL's <evp.h> 和sasl.h not found!
编译mongodb拓展出现 Cannot find OpenSSL's <evp.h> 解决方法:安装openssl yum install openssl openssl-devel 出 ...
- Linux显示所有运行中的进程
Linux显示所有运行中的进程 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ ps aux | less USER PID %CPU %MEM VSZ RSS ...
- HTML5不允许写结束标记的元素
HTML5不允许写结束标记的元素 1.area 2.base 3.br 4.col 5.command 6.embed 7.img 8.hr 9.keygen 10.link 11.meta 12.p ...
- directX视频播放------手动连接
IGraphBuilder *pigb = NULL; IMediaControl *pimc = NULL; IMediaEventEx *pimex = NULL; IVideoWindow *p ...
- Docker 小记 — Compose & Swarm
前言 任何相对完整的应用服务都不可能是由单一的程序来完成支持,计划使用 Docker 来部署的服务更是如此.大型服务需要进行拆分,形成微服务集群方能增强其稳定性和可维护性.本篇随笔将对 Docker ...
- hdu5887 Herbs Gathering
神他妈随便写写就能过- 暴力枚举每个取不取 两个剪纸: 1.当剩下可用的时间小于最少需要用的时间 跳出 2.当剩下的植物按照理想情况(甚至可以取一部分)得到的极限答案比已经求出的答案大 跳出 #inc ...
- 通过ApplicationContext.getBean(beanName)动态加载数据。
一,前台数据 $.ajax({ url: '/intra/coe/order/ploadTable.htm', type: 'POST', dataType: 'json', data: {keyId ...
- ASP.NET Core 2.0: 二. 开发环境
macOS:Install Visual Studio for Mac 系统要求: macOS 10.12 Sierra 及更高版本 其他要求: 可能会要求安装xcode或android相关环境, 详 ...