国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

React Native實現簡單的登錄功能(推薦)

2019-11-20 08:57:09
字體:
來源:轉載
供稿:網友

React Native 簡介:

React Native 結合了 Web 應用和 Native 應用的優勢,可以使用 JavaScript 來開發 iOS 和 Android 原生應用。在 JavaScript 中用 React 抽象操作系統原生的 UI 組件,代替 DOM 元素來渲染等。

React Native 使你能夠使用基于 JavaScript 和 React 一致的開發體驗在本地平臺上構建世界一流的應用程序體驗。React Native 把重點放在所有開發人員關心的平臺的開發效率上――開發者只需學習一種語言就能輕易為任何平臺高效地編寫代碼。Facebook 在多個應用程序產品中使用了 React Native,并將繼續為 React Native 投資。

學習React Native也有2個月了,從最開始的頁面到點點擊事件,到調用接口大體都會了,今天實現一個簡單的登錄功能。

這里需要說明幾點:

1、<TextInput>組件在React Native中,默認是帶一條橫線的,如果想去掉輸入框下面的橫線,需要給<TextInput>指定一個underlineColorAndroid='transparent',這樣就可以去掉輸入框下面的橫線了;

2、密碼輸入框需要指定屬性:secureTextEntry={true}

3、要顯示圖片,必須為<Image>標簽指定寬度和高度,和Android中不同的是,<Image>沒法自動調整圖片的大小,沒有類似Android中的wrap_content。

代碼如下:

/** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, {Component} from 'react'; import { AppRegistry, StyleSheet, Text, Image, View, TextInput } from 'react-native'; class ReactDemo extends Component { render() { return ( <View style={styles.container}> <View style={styles.header}> <Text style={styles.headtitle}>添加賬號</Text> </View> <View style={styles.marginTopview}/> <View style={styles.inputview}> <TextInput underlineColorAndroid='transparent' style={styles.textinput} placeholder='QQ號/手機號/郵箱'/> <View style={styles.dividerview}> <Text style={styles.divider}></Text> </View> <TextInput underlineColorAndroid='transparent' style={styles.textinput} placeholder='密碼' secureTextEntry={true}/> </View> <View style={styles.bottomview}> <View style={styles.buttonview}> <Text style={styles.logintext}>登 錄</Text> </View> <View style={styles.bottombtnsview}> <View style={styles.bottomleftbtnview}> <Text style={styles.bottombtn}>無法登錄?</Text> </View> <View style={styles.bottomrightbtnview}> <Text style={styles.bottombtn}>新用戶</Text> </View> </View> </View> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#FFFFFF' }, header: { height: 50, backgroundColor: '#12B7F5', justifyContent: 'center', }, headtitle: { alignSelf: 'center', fontSize: 20, color: '#ffffff', }, avatarview: { height: 150, backgroundColor: '#ECEDF1', justifyContent: 'center', }, avatarimage: { width: 100, height: 100, alignSelf: 'center' }, marginTopview: { height: 15, backgroundColor: '#F7F7F9' }, inputview: { height: 100, }, textinput: { flex: 1, fontSize: 16, }, dividerview: { flexDirection: 'row', }, divider: { flex: 1, height: 1, backgroundColor: '#ECEDF1' }, bottomview: { backgroundColor: '#ECEDF1', flex: 1, }, buttonview: { backgroundColor: '#1DBAF1', margin: 10, borderRadius: 6, justifyContent: 'center', alignItems: 'center', }, logintext: { fontSize: 17, color: '#FFFFFF', marginTop: 10, marginBottom: 10, }, emptyview: { flex: 1, }, bottombtnsview: { flexDirection: 'row', }, bottomleftbtnview: { flex: 1, height: 50, paddingLeft: 10, alignItems: 'flex-start', justifyContent: 'center', }, bottomrightbtnview: { flex: 1, height: 50, paddingRight: 10, alignItems: 'flex-end', justifyContent: 'center', }, bottombtn: { fontSize: 15, color: '#1DBAF1', } }); AppRegistry.registerComponent('ReactDemo', () => ReactDemo);

以上所述是小編給大家介紹的React Native實現登錄功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 钟祥市| 特克斯县| 调兵山市| 石首市| 惠东县| 富裕县| 洛浦县| 临澧县| 高台县| 环江| 武安市| 玉龙| 马尔康县| 娄底市| 鸡西市| 黔南| 瑞昌市| 乐亭县| 武城县| 读书| 汕尾市| 怀安县| 五河县| 左贡县| 铁岭县| 高雄县| 南溪县| 遂宁市| 钟山县| 囊谦县| 波密县| 桂东县| 西丰县| 东源县| 乐东| 武安市| 正定县| 淮安市| 南雄市| 鄱阳县| 丰县|