加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Vue验证码60秒倒计时功能简单实例代码

发布时间:2020-12-17 03:11:29 所属栏目:百科 来源:网络整理
导读:template script css(scss写法) 总结 以上所述是小编给大家介绍的Vue验证码60秒倒计时功能简单实例代码。编程之家 jb51.cc 收集整理的教程希望能对你有所帮助,如果觉得编程之家不错,可分享给好友!感谢支持。

template

script

export default { data() { return { // 是否禁用按钮 codeDisabled: false,// 倒计时秒数 countdown: 60,// 按钮上的文字 codeMsg: '获取验证码',// 定时器 timer: null } },methods: { // 获取验证码 getCode() { // 验证码60秒倒计时 if (!this.timer) { this.timer = setInterval(() => { if (this.countdown > 0 && this.countdown <= 60) { this.countdown--; if (this.countdown !== 0) { this.codeMsg = "重新发送(" + this.countdown + ")"; } else { clearInterval(this.timer); this.codeMsg = "获取验证码"; this.countdown = 60; this.timer = null; this.codeDisabled = false; } } },1000) } } } }

css(scss写法)

.login{ width: 100%; height: 100%; background: #F9F9F9; .loginHeader{ padding: 0 10px; background: #fff; margin-top: 20px; overflow: hidden; .loginBtn{ width: 100%; height: 42px; border: none; background: #fff; color: #444; border-radius: 4px; outline: none; padding-left: 3px; font-size: 1.4rem; box-sizing: border-box; -webkit-appearance:none; } .border-bottom{ border-bottom: 1px solid #F3F3F3; } .codeBtn{ width: 63%; height: 42px; border: none; background: #fff; color: #444; border-radius: 4px; float: left; outline: none; padding-left: 3px; font-size: 1.4rem; box-sizing: border-box; -webkit-appearance:none; } .getNumber{ width: 35%; height: 36px; float: right; margin-top: 3px; border: 1px solid #09BB07; color: #09BB07; background: #fff; border-radius: 4px; outline: none; -webkit-appearance:none; } } }

总结

以上所述是小编给大家介绍的Vue验证码60秒倒计时功能简单实例代码。编程之家 52php.cn 收集整理的教程希望能对你有所帮助,如果觉得编程之家不错,可分享给好友!感谢支持。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读