傳送簡訊驗證碼時的倒計時功能
阿新 • • 發佈:2019-01-06
this.show = false; const TIME_COUNT = 60; if (!this.timer) { this.count = TIME_COUNT; this.timer = setInterval(() => { if (this.count > 0 && this.count <= TIME_COUNT) { this.count--; //將秒數複製給你要顯示的文字 this.btnText = this.count+' s' } else { this.show = true; clearInterval(this.timer); this.timer = null; this.btnText = "重新發送"; } }, 1000) }
別忘了定義show和count哦~~