欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

react如何實現(xiàn)密碼隱藏功能

這篇文章主要講解了“react如何實現(xiàn)密碼隱藏功能”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“react如何實現(xiàn)密碼隱藏功能”吧!

創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供羅山網(wǎng)站建設、羅山做網(wǎng)站、羅山網(wǎng)站設計、羅山網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、羅山企業(yè)網(wǎng)站模板建站服務,十多年羅山做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。

react實現(xiàn)密碼隱藏功能的方法:1、添加依賴“import {View,Text,TouchableWithoutFeedback,TextInput,Image,StyleSheet,} from 'react-native';”;2、通過“{this.state.imageState ? (...)}”方法實現(xiàn)密碼顯示與隱藏功能即可。

React Native 密碼輸入的顯示與隱藏 Image點擊事件 眼睛 輸入框密碼

1.效果圖

react如何實現(xiàn)密碼隱藏功能

react如何實現(xiàn)密碼隱藏功能

2.添加依賴

import {
  View,
  Text,
  TouchableWithoutFeedback,
  TextInput,
  Image,
  StyleSheet,
} from 'react-native';

3.代碼功能實現(xiàn)

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      imageState: false,
    };
  }
  render() {
    return (
      <View style={{ flex: 1, justifyContent: 'space-around' }}>
        <View
          style={{ backgroundColor: '#ffffff', height: 50, flexDirection: 'row', justifyContent: 'space-between', marginTop: 1, }}>
          <Text style={pageStyle.textStyle}>請輸入密碼:</Text>
          <TextInput
            secureTextEntry={!this.state.imageState}//是否隱藏
            editable={true}//是否可編輯
            style={pageStyle.textInfoStyle}>
            test12345test
          </TextInput>
          <TouchableWithoutFeedback style={{ marginRight: 10 }} onPress={this.onPressChang}>
            {this.state.imageState ? (
              <Image style={{ width: 21, height: 14, alignSelf: 'center', marginRight: 10, }}
                source={require('../ReactDemo1/android/app/src/main/res/mipmap-xhdpi/password_show.png')}
              />) : (<Image style={{ width: 20, height: 8, alignSelf: 'center', marginRight: 10, }}
                source={require('../ReactDemo1/android/app/src/main/res/mipmap-xhdpi/password_hide.png')}
              />)}
          </TouchableWithoutFeedback>
        </View>
      </View>
    );
  }
  onPressChang = () => {
    this.setState({
      imageState: !this.state.imageState,
    });
  };
}
const pageStyle = StyleSheet.create({
  textInfoStyle: {
    alignSelf: 'center',
    marginLeft: 40,
    color: '#343434',
    fontSize: 16,
    flex: 1,
  },
  textStyle: {
    alignSelf: 'center',
    marginLeft: 10,
    color: '#343434',
    fontSize: 16,
  },
});

感謝各位的閱讀,以上就是“react如何實現(xiàn)密碼隱藏功能”的內容了,經(jīng)過本文的學習后,相信大家對react如何實現(xiàn)密碼隱藏功能這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關知識點的文章,歡迎關注!

網(wǎng)頁名稱:react如何實現(xiàn)密碼隱藏功能
標題鏈接:http://chinadenli.net/article18/jgcidp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供云服務器、網(wǎng)站設計、外貿建站、網(wǎng)站維護、網(wǎng)站策劃、品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

h5響應式網(wǎng)站建設