微信小程序分、秒倒计时,补零
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了微信小程序分、秒倒计时,补零相关的知识,希望对你有一定的参考价值。
参考技术A <view>min:sec</view>//计时器,cycleTime为豪秒数
timerSec(cycleTime)
var that = this
let intervalsec = null //倒计时函数
intervalsec = setInterval(function()
cycleTime--;
that.setData(
min: parseInt(cycleTime / 60) < 10 ? '0' + parseInt(cycleTime / 60) : parseInt(cycleTime / 60),
sec: (cycleTime % 60) < 10 ? '0' + (cycleTime % 60) : (cycleTime % 60),
)
if (cycleTime == 0)
clearInterval(intervalsec)
, 1000)
,
微信小程序获取验证码倒计时
getVerificationCode: function() { var that = this; var currentTime = that.data.currentTime; that.setData({ codename: currentTime + ‘秒‘, disabled:true }) var interval = setInterval(function() { that.setData({ codename: (currentTime - 1) + ‘秒‘ }) currentTime--; if (currentTime <= 0) { clearInterval(interval) that.setData({ codename: ‘重新获取‘, currentTime: 60, disabled: false }) } }, 1000) },
以上是关于微信小程序分、秒倒计时,补零的主要内容,如果未能解决你的问题,请参考以下文章