React-Native实现登录页面,并显示和清除用户的输入
来源:互联网 发布:孔莹网络春晚 编辑:程序博客网 时间:2024/06/05 03:28
/** * Sample React Native App * https://github.com/facebook/react-native * ES6实现代码 */import React, {Component} from 'react';import { AppRegistry, StyleSheet, Text, View, TextInput} from 'react-native';let Dimensions = require('Dimensions');let totalWidth = Dimensions.get('window').width;let leftStartPoint = totalWidth * 0.1;let componentWidth = totalWidth * 0.8;export default class Project1 extends Component { constructor (props){ super(props); this.state = { inputedNum:'', inputedPW:'' }; //下面两条语句将两个回调函数和成员方法绑定 this.updateNum = this.updateNum.bind(this); this.updatePW = this.updatePW.bind(this); this.buttonPressed = this.buttonPressed.bind(this); } updateNum(newText) { this.setState((state) => { return { inputedNum:newText }; }); } updatePW(newText) { this.setState((state) => { return { inputedPW:newText }; }); } buttonPressed(){ this.setState((state) => { return { inputedNum:'' }; }); } render() { return ( <View style={styles.container}> <TextInput style={styles.numberInputStyle} placeholder={'请输入手机号'} onChangeText={(newText) => this.updateNum(newText)}/> <Text style={styles.textPromptStyle}> 请输入您的手机号:{this.state.inputedNum}//代码联动显示用户的手机号输入 </Text> <TextInput style={styles.passwordInputStyle} placeholder={'请输入密码'} password={true} onChangeText={(newText) => this.updatePW(newText)}/> <Text style={styles.bigTextPrompt} onPress = {this.buttonPressed}>//代码联动删除用户的手机号输入 确 定 </Text> </View> ); }}const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', backgroundColor: '#F5FCFF', }, numberInputStyle: { top: 20, left: leftStartPoint, width: componentWidth, backgroundColor:'gray', fontSize: 20, }, textPromptStyle: { top: 30, left: leftStartPoint, width: componentWidth, fontSize: 20, }, passwordInputStyle: { top: 50, left: leftStartPoint, width: componentWidth, backgroundColor:'gray', fontSize: 20, }, bigTextPrompt: { top: 70, left: leftStartPoint, width: componentWidth, backgroundColor:'gray', color:'white', textAlign:'center', fontSize: 60, },});AppRegistry.registerComponent('Project1', () => Project1);
阅读全文
0 0
- React-Native实现登录页面,并显示和清除用户的输入
- react-native统一入口界面,并实现页面的跳转
- React-Native 背景图片全屏显示及登录页面
- React Native 仿登录页面
- React-Native学习笔记之:实现简单地登录页面
- react-native 页面切换的实现
- React Native实现Text显示...的效果
- 实现不同用户登录显示不同页面
- (八)React Native实现调用android原生java方法并实现广播的发送和接受
- React Native边学边做(二)登录页面
- React-Native 自定义TextInput 登录页面
- 关于页面显示当前登录的用户
- JSP实现简单的用户登录,并显示出用户的信息
- react-native页面的跳转
- react实现登录页面demo
- react-native 完整实现登录功能
- React-Native 实现QQ登录界面
- react-native 完整实现登录功能
- 【真题 腾讯】满二叉搜索树求三个节点的最低公共祖先
- android创建自定义控件步骤
- 搭建elsticsearch集群 报错with the same id but is a different node instance解决办法
- bootstrap-treeview 中文api
- 多线程学习之路-学习master-worker设计模式
- React-Native实现登录页面,并显示和清除用户的输入
- oracle中的函数介绍(一):nvl函数、decode函数、case when函数、sum函数
- OSI七层与TCP/IP五层网络架构,个人理解,通过一个http请求的全过程,分析在协议栈中的流转过程
- AndroidStudio-mac
- linux下安装gcc
- 是否可以联网 wininet
- css-组合选择器
- Ubuntu14.04下使用QTcreator构建OpenCV工程
- 大数据各软件框架启动命令行