Applet micro-channel transmission function codes, codes countdown

data{
        timer:'',
        countDownNum: ' Send code ' ,
    }
    // click countdown codes acquired codes 
    Gain: function (e) {
        let that = this
        let countDownNum = '60'
        that.setData({
          timer: setInterval (function () { // Here the setInterval assigned to a variable called the variable timer
             // every second countDownNum decremented by one synchronization 
            countDownNum-- ;
             // then deposited into countDownNum Data, so that the user I know the time countdown 
            that.setData ({
              countDownNum: countDownNum+'s'
            })
            // In the countdown to zero yet, this intermediate can do other things, according to project requirements to 
            IF (countDownNum == 0 ) {
               // here with particular attention to the timer is always been to go, if your time 0, then it would turn off the timer! Otherwise, considerable resistance performance
               // because timer data is present inside, so that when turned off, but also in the data taken before shut down in 
              clearInterval (that.data.timer);
              that.setData({
                countDownNum: ' Send code '
              })
              // After closing timer can be used for other processing Go here Wallpaper Codes 
            }
          }, 1000)
        })
      },

 

Guess you like

Origin www.cnblogs.com/wuliujun521/p/11775375.html