>  기사  >  위챗 애플릿  >  미니 프로그램: 클릭 카운트다운을 구현하는 코드

미니 프로그램: 클릭 카운트다운을 구현하는 코드

不言
不言원래의
2018-08-10 15:44:023023검색

이 글의 내용은 미니 프로그램에 관한 것입니다. 클릭 카운트다운을 구현하는 코드에는 특정 참조 값이 있습니다. 도움이 필요한 친구들이 참고할 수 있기를 바랍니다.

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: &#39;重新发送&#39;,
          currentTime:61,
          disabled: false   
        })
      }
    }, 100)  
  },
  getVerificationCode(){
    this.getCode();
    var that = this
    that.setData({
      disabled:true
    })
  },

})
<button disabled=&#39;{{disabled}}&#39; data-id="2" bindtap="getVerificationCode">
{{time}}
</button>

관련 추천:

미니 프로그램 구성 요소: 채팅 세션 구성 요소 소개(코드 포함)

미니 프로그램과 배경 간의 상호 작용 구현(코드 포함)

위 내용은 미니 프로그램: 클릭 카운트다운을 구현하는 코드의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.