wxml:
<button class="btn" bindtap="{{bindEndClick}}">{{phoneNum}}</button>
js:
Page({
? data: {
? ? phoneNum: '獲取驗(yàn)證碼',
? ? bindEndClick:'clickEnd'
? },
? clickEnd() {
? ? var _this = this
? ? var numberNum = 61
? ? var setinter = setInterval(function() {
? ? ? numberNum = numberNum - 1
? ? ? if (_this.data.phoneNum == 0) {
? ? ? ? _this.setData({
? ? ? ? ? phoneNum: "重新獲取"
? ? ? ? })
? ? ? ? clearInterval(setinter);
? ? ? } else {
? ? ? ? _this.setData({
? ? ? ? ? phoneNum: numberNum,
? ? ? ? ? bindEndClick:''
? ? ? ? })
? ? ? ? console.log("1")
? ? ? }
? ? }, 1000)
? }
})