var length = 60; function countdown(that) { that.setData({ captchaDisabled: true, captchaLabel: length + '秒后重新发送' }); setTimeout(() => { if (length <= 1) { length = 60 that.setData({ captchaDisabled: false, captchaLabel: "获取验证码" }); return false; } else { length--; that.setData({ captchaDisabled: true, captchaLabel: length + '秒后重新发送' }); } countdown(that) }, 1000) } module.exports = countdown