本文實例為大家分享了微信小程序實現獲取驗證碼倒計時效果的具體代碼,供大家參考,具體內容如下
wxml
<button disabled='{{disabled}}' data-id="2" bindtap="getVerificationCode"> {{time}} </button>
js
var interval = null //倒計時函數 Page({ data: { date:'請選擇日期', fun_id:2, time: '獲取驗證碼', //倒計時 currentTime:61 }, getCode: function (options){ var that = this; var currentTime = that.data.currentTime interval = setInterval(function () { currentTime--; that.setData({ time: currentTime+'秒' }) if (currentTime <= 0) { clearInterval(interval) that.setData({ time: '重新發送', currentTime:61, disabled: false }) } }, 100) }, getVerificationCode(){ this.getCode(); var that = this that.setData({ disabled:true }) }, })
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com