小程序定时器
发布日期:2021-05-07 00:08:39 浏览次数:29 分类:技术文章

本文共 673 字,大约阅读时间需要 2 分钟。

一,简单框架
/*
验证码的获取
*/
btn_getYZM_event:
function(){
var c=this.counttime(this)
},
//这里的that,this常常会忘记写,然后会出现函数没有定义的错误。
counttime:
function(that){
setTimeout(
function () {
console.log(
"获取验证码。");
var c = that.counttime(that)//自己调用自己
},
1000)
//延迟时间 这里是1秒
},
二,完善后
/*
验证码的获取
*/
btn_getYZM_event:
function(){
var c=
this.counttime(
this)
},
counttime:
function(that){
setTimeout(
function () {
that.setData({
second: that.data.second -
1
})
if (that.data.second >
0) {
var c = that.counttime(that)
that.setData({
btn_regiter_txt: that.data.second
})
}
else {
that.setData({
btn_getYZM_event:
"btn_getYZM_event",
btn_regiter_txt:
"获 取",
second:
60,
})
}
},
1000)
//延迟时间 这里是1秒
},
上一篇:fileupload导包的没有定义问题
下一篇:js,小程序共用java后端进行数据传输

发表评论

最新留言

表示我来过!
[***.240.166.169]2025年03月17日 23时36分16秒