由于最近一直在做公司的项目,而且比较急。如今项目已经迭代到第三期,可以缓一缓了。。。
说实话,最近一直再用android做开发,而且时间也不宽裕,react-native有点生疏了。
好了,废话不多说,今天在做登录界面的时候,我发现,登录注册的文本框样式都是一个样的,如果一个一个的写,就会显得有些麻烦了,于是我就简单的封装了一下TextInput这一个组件
上图就是我放到登录界面的效果啦。
代码:
import React, { Component } from 'react'; import { Text, TextInput, View, PropTypes, StyleSheet, ToastAndroid } from 'react-native' class TextInputLogin extends Component { static propTypes = { name: React.PropTypes.string, txtHide: React.PropTypes.string, ispassword: React.PropTypes.bool } static defaultProps = { name: '名称', txtHide: '内容', ispassword: false, } constructor (props) { super (props) this.state = { txtValue: "", } } render () { var { style, name, txtHide, ispassword } = this.props return( <View style={styles.container,style}> <View style={styles.txtBorder}> <Text style={styles.txtName}>{name}</Text> <TextInput underlineColorAndroid = {'transparent'} style={styles.textInput} multiline={false} placeholder={txtHide} password={ispassword} onChangeText={(text) => { this.setState({ txtValue: text }) }} value={this.state.txtValue} /> </View> </View> ) } getValue () { return this.state.txtValue } } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', flexDirection: 'row' }, txtBorder: { height: 50, flex: 1, borderWidth: 1, borderColor: '#51A7F9', marginLeft: 50, marginRight: 50, borderRadius: 25, flexDirection: 'row' }, txtName: { height: 20, width: 40, marginLeft: 20, fontSize: 15, marginTop: 15, color: '#51A7F9', marginRight: 10, fontSize: 14 }, textInput: { height: 50, width: 200 } }) module.exports = TextInputLogin;
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月25日
2024年09月25日
- 黄心懋1991-轻忧郁【滚石】【WAV+CUE】
- 群星.2000-大地金曲世纪回顾2CD【大地】【WAV+CUE】
- 王菲.1996-浮躁(2024环球MQA-UHQCD限量版)【环球】【WAV+CUE】
- 群星.2022-传家电视剧原声带【东阳欢娱】【FLAC分轨】
- 《摇滚教父 伍佰黄金精选 2CD》 [WAV+CUE][1GB]
- 《凤凰传奇 我从草原来》[WAV/分轨][400MB]
- 《叶倩文 真心真意过一生》[WAV+CUE][400MB]
- 潘越云.1985-世间女子(滚石25周年经典复刻版)【滚石】【WAV+CUE】
- 陈柏宇.2009-CANT.BE.HALF【SONY】【WAV+CUE】
- 李明依.1989-小女生【滚石】【WAV+CUE】
- 《李荣浩 新时代创作新人王》[WAV分轨][310MB]
- 《黑鸭子与马头琴 史上最动听草原音乐》[WAV+CUE][320MB]
- 《汽车发烧音乐精选CD18》[FLAC+CUE][7.1G]
- 郑希怡.2004-Perfect.Date【英皇娱乐】【FLAC分轨】
- 群星.1994-宝丽金超级孖宝2CD【宝丽金】【WAV+CUE】