本文主要为大家介绍了如何简单实现vue验证码60秒倒计时功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能帮助到大家。
html
<span v-show="show" @click="getCode">获取验证码</span> <span v-show="!show" class="count">{{count}} s</span>
js
data(){ return { show: true, count: '', timer: null, } }, methods:{ getCode(){ const TIME_COUNT = 60; if (!this.timer) { this.count = TIME_COUNT; this.show = false; this.timer = setInterval(() => { if (this.count > 0 && this.count <= TIME_COUNT) { this.count--; } else { this.show = true; clearInterval(this.timer); this.timer = null; } }, 1000) } } }
相关推荐:
立即学习“前端免费学习笔记(深入)”;
js代码实现点击按钮出现60秒倒计时_javascript技巧
以上就是vue实现验证码60秒倒计时功能简单实例的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号