亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

微信小程序6位或多位驗(yàn)證碼密碼輸入框功能的實(shí)現(xiàn)代碼

 更新時(shí)間:2018年05月29日 11:38:59   作者:熱忱學(xué)習(xí)  
這篇文章主要介紹了微信小程序6位或多位驗(yàn)證碼密碼輸入框功能的實(shí)現(xiàn)代碼,實(shí)現(xiàn)思路很簡(jiǎn)單,需要的朋友可以參考下

在做小程序過程中做一個(gè)6位驗(yàn)證碼輸入框,本以為很簡(jiǎn)單,但是在寫的時(shí)候遇到各種各樣的阻力,在網(wǎng)上查閱資料也寥寥無幾,后來經(jīng)過一番思考,終于敲定下來本人最滿意的方案,特意發(fā)出來讓大家參考一下,希望能幫到大家!

一、效果圖如下:


二、代碼部分

wxml:

<form bindsubmit="formSubmit"> 
 <view class='content'> 
  <block wx:for="{{Length}}" wx:key="item"> 
   <input class='iptbox' value="{{Value.length>=index+1?Value[index]:''}}" disabled password='{{ispassword}}' catchtap='Tap'></input> 
  </block> 
 </view> 
 <input name="password" password="{{true}}" class='ipt' maxlength="{{Length}}" focus="{{isFocus}}" bindinput="Focus"></input> 
 <view> 
  <button class="btn-area" formType="submit">Submit</button> 
 </view> 
</form> 

js:

Page({ 
 /** 
  * 頁面的初始數(shù)據(jù) 
  */ 
 data: { 
  Length:6,    //輸入框個(gè)數(shù) 
  isFocus:true,  //聚焦 
  Value:"",    //輸入的內(nèi)容 
  ispassword:true, //是否密文顯示 true為密文, false為明文。 
 }, 
 Focus(e){ 
  var that = this; 
  console.log(e.detail.value); 
  var inputValue = e.detail.value; 
  that.setData({ 
   Value:inputValue, 
  }) 
 }, 
 Tap(){ 
  var that = this; 
  that.setData({ 
   isFocus:true, 
  }) 
 }, 
 formSubmit(e){ 
  console.log(e.detail.value.password); 
 }, 
}) 

wxss:

content{ 
 display: flex; 
 justify-content: space-around; 
 align-items: center; 
 margin-top: 200rpx; 
} 
iptbox{ 
 width: 80rpx; 
 height: 80rpx; 
 border:1rpx solid #ddd; 
 border-radius: 20rpx; 
 display: flex; 
 justify-content: center; 
 align-items: center; 
 text-align: center; 
} 
ipt{ 
 width: 0; 
 height: 0; 
} 
btn-area{ 
 width: 80%; 
 background-color: orange; 
 color:white; 
} 

三、思路:

1、放置一個(gè)輸入框,隱藏其文字和位置,同時(shí)設(shè)置支付輸入框(表格)樣式
2、當(dāng)點(diǎn)擊輸入框時(shí)設(shè)置輸入框?yàn)榫劢範(fàn)顟B(tài),喚起鍵盤,點(diǎn)擊空白處,失去焦點(diǎn),設(shè)為失去焦點(diǎn)樣式,因?yàn)檩斎肟驅(qū)捀邽?,所以不會(huì)顯示輸入框和光標(biāo),實(shí)現(xiàn)隱藏。
3、限制輸入框最大字?jǐn)?shù)并且監(jiān)聽輸入框狀態(tài),以輸入框值的長(zhǎng)度作為輸入框(表格)內(nèi)容的渲染條件
4、點(diǎn)擊提交按鈕時(shí),獲取輸入框內(nèi)容。

總結(jié)

以上所述是小編給大家介紹的微信小程序6位或多位驗(yàn)證碼密碼輸入框功能的實(shí)現(xiàn)代碼,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論