wangyuyuan

var currentTime = 59 //倒计时的事件(单位:s)
var interval = null //倒计时函数

Page({
data: {
time:59 //倒计时
},
onLoad:function(){
this.countdown();
},
// 倒计时
countdown:function(){
var that = this;
interval = setInterval(function () {
currentTime--;
that.setData({
time: currentTime
})

if (currentTime <= 0) {
clearInterval(interval)
currentTime = -1
}
}, 1000)
}

}

分类:

技术点:

相关文章:

  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2021-09-25
猜你喜欢
  • 2021-11-23
  • 2022-01-01
  • 2022-01-01
  • 2021-12-08
  • 2022-12-23
  • 2021-12-05
  • 2021-11-25
相关资源
相似解决方案