短信验证码需要做一个计时器,我看官方给的计时器好麻烦,有什么简单的做法吗?请各位大佬不吝赐教
经过一位热心大佬的帮忙,已经实现了,万分感谢,有同样的小白不会做的话,可以看一下,可能没有比我菜的了,哈哈(手动滑稽)
broadcostTimes = 60
start () {
// 倒计时
this.schedule(this.doCountdownTime,1);
}
//倒计时
doCountdownTime(){
//每秒更新显示信息
if (this.broadcostTimes > 0 ) {
this.broadcostTimes -= 1;
this.countDownShow(this.broadcostTimes);
}
}
countDownShow(temp:number){
if(temp <= 0){
//倒计时结束
this.unschedule(this.doCountdownTime);
//执行其他操作
}
}
多谢 本人也是新手
那个东西会每隔一秒执行doCountdownTime方法,就可以倒计时了
你拿个表掐一下,倒计时结束肯定不止60S