Skip to content

Instantly share code, notes, and snippets.

@stefango
Created June 29, 2020 05:18
Show Gist options
  • Save stefango/9cc47764134d9b00894cbe78afb8596e to your computer and use it in GitHub Desktop.
Save stefango/9cc47764134d9b00894cbe78afb8596e to your computer and use it in GitHub Desktop.
获取验证码片段
getCode() {
this.isLoading = true
this.isDisable = true
let time = 10;
this.getCodeButtonValue = time + '秒后重试'
let task = setInterval(() => {
time--;
this.getCodeButtonValue = time + '秒后重试'
console.log("task - " + time)
}, 1000)
setTimeout(() => {
this.isLoading = false
this.isDisable = false
this.getCodeButtonValue = '获取验证码'
clearInterval(task)
console.log('timeout')
}, 10 * 1000)
console.log('END')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment