微信小程序验证码获取倒计时


wxml
js
data:{
disabled: false,
code: '获取验证码',
},
goGetCode:function(){
var that = this;
var time = 60;
that.setData({
code: '60秒后重发',
disabled: true
})
var Interval = setInterval(function() {
time--;
if (time>0){
that.setData({
code: time + '秒后重发'
})
}else{
clearInterval(Interval);
that.setData({
code: '获取验证码',
disabled: false
})
}
},1000)
}
wxss
button{
width:260rpx;
height:80rpx;
padding: 10rpx 0;
color: #000;
line-height: 50rpx;
font-size: 32rpx;
color: #fff;
background: green;
}
button[disabled]:not([type]){
background: red;
color: #fff;
}
微信小程序验证码获取倒计时
wxml
js
data:{
disabled: false,
code: '获取验证码',
},
goGetCode:function(){
var that = this;
var time = 60;
that.setData({
code: '60秒后重发',
disabled: true
})
var Interval = setInterval(function() {
time--;
if (time>0){
that.setData({
code: time + '秒后重发'
})
}else{
clearInterval(Interval);
that.setData({
code: '获取验证码',
disabled: false
})
}
},1000)
}
wxss
button{
width:260rpx;
height:80rpx;
padding: 10rpx 0;
color: #000;
line-height: 50rpx;
font-size: 32rpx;
color: #fff;
background: green;
}
button[disabled]:not([type]){
background: red;
color: #fff;
}
微信小程序用setData修改数组或对象中的一个属性值


主看部分wxml
全部

浙公网安备 33010602011771号