支付寶小程序擴(kuò)展表單 驗證碼輸入框·VerifyCode

2020-09-18 11:22 更新

驗證碼輸入框。

受控模式,使用時需要用 onInput 事件來回設(shè) value。

掃碼體驗

示例代碼

{
  "defaultTitle": "Verify-code",
  "usingComponents": {
    "verify-code": "mini-ali-ui/es/verify-code/index"
  }
}
<view>
  <view style="margin-top: 10px;" />
  <view style="padding: 0 10px;">驗證碼框</view>
  <view style="margin-top: 10px;" />
  <verify-code
    onInput="onInput" 
    value="{{verifyCode}}" 
    onClear="onClear" 
    last="{{true}}" 
    countDown="{{10}}" 
    initActive="{{false}}"
    onSend="onSend"></verify-code>
</view>
Page({
  data: {
    verifyCode: '',
  },
  onSend() {
    my.alert({
      title: 'verify code sent',
    });
  },
  onInput(e) {
    this.setData({
      verifyCode: e.detail.value,
    });
  },
});

屬性

屬性 類型 默認(rèn)值 描述 最低版本
className String - 自定義的 class。 -
label String 驗證碼 自定義 label 文案。 -
labelCls String - 自定義 label 的 class。 -
inputCls String - 自定義 input 的 class -
last Boolean false 是否為最后一行。 -
value String - 輸入框值。 -
name String - 組件名字,用于表單提交獲取數(shù)據(jù)。 -
placeholder String - 占位符。 -
placeholderStyle String - 指定 placeholder 的樣式。 -
placeholderClass String - 指定 placeholder 的樣式類。 -
disabled Boolean false 是否禁用。 -
maxlength Number 140 最大長度。 -
focus Boolean false 獲取焦點。 -
clear Boolean true 是否帶清除功能,僅 disabled 為 false 才生效。 -
onInput (e: Object) => void - 鍵盤輸入時觸發(fā) input 事件。 -
onConfirm (e: Object) => void - 點擊鍵盤完成時觸發(fā)。 -
onFocus (e: Object) => void - 聚焦時觸發(fā)。 -
onBlur (e: Object) => void - 失去焦點時觸發(fā)。 -
onClear () => void - 點擊清除 icon 時觸發(fā)。 -
txtSend String 發(fā)送驗證碼 發(fā)送按鈕的默認(rèn)文案 1.1.2
txtSendAgain String 重發(fā)驗證碼 重發(fā)按鈕的默認(rèn)文案 1.1.2
txtCountDown String 秒后重試 按鈕倒計時的默認(rèn)文案(不包含倒計時) 1.1.2
initActive Boolean false 是否主動觸發(fā)發(fā)送按鈕。 1.1.3

Bug & Tip

  • 當(dāng) initActive 為 true 時,組件在初次加載后就會自動進(jìn)入倒計時狀態(tài);如需要在該狀態(tài)下有提示信息展示,需自行處理。
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號