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,它们就是 ...
随机推荐
- Apple 内购
关于内购所需东西: 1.测试开发证书:需要打开in-app-purchase,绑定bundleid:com.aragon.TexasPoker 2.iTunes connect 里添加内购应用: 1& ...
- Android(Java)利用findbugs进行代码静态检查
主要介绍利用java静态代码检查工具findbugs进行代码检查,包括其作用.安装.使用.高级功能(远程review和bug同步). 虽然Android提供了Test Project工程以及instr ...
- dojo拼接成CSV格式字符串
var student = "学号,姓名,年龄\n"; for(var i = 0;i<resp.items.length;i++) { student += resp.it ...
- ClientAbortException: java.net.SocketException: Software caused connection abort: socket write erro
1.错误描述 ClientAbortException: java.net.SocketException: Software caused connection abort: socket writ ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxError Exception
1.错误描述 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxError Exception:You have an error in your SQL synt ...
- C#扩展方法类库StringExtensions
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 用VSCode开发一个asp.net core 2.0+angular 5项目(4): Angular5全局错误处理
第一部分: http://www.cnblogs.com/cgzl/p/8478993.html 第二部分: http://www.cnblogs.com/cgzl/p/8481825.html 第三 ...
- [BZOJ1385] [Baltic2000] Division expression (数学)
Description 除法表达式有如下的形式: X1/X2/X3.../Xk 其中Xi是正整数且Xi<=1000000000(1<=i<=k,K<=10000) 除法表达式应 ...
- java怎么解析带有特殊字符的字符串
可以使用StringEscapeUtils这个工具类.
- 进一步理解阿贾克斯(Ajax)
一.ajax简介 1.Asynchronous JavaScript and XML(异步的Javascript和XML) 2.是一种在无需重新加载整个网页的情况下能够更新部分网页的技术. 二.aja ...