倒计时小功能

if (this.flag) {if (this.time < 119) { return;}Services.getLoginSmsCode({ sendTarget: this.$route.query.phone }).then( res => { console.log(res); if (res.code != "0000") { this.$toast(res.msg); this.flag = true; return; } let timer = setInterval(() => { if (this.time > 1) { this.time--; } else { this.time = 120; clearInterval(timer); this.flag = true; } }, 1000); });}this.flag = false;

你可能感兴趣的:(倒计时小功能)