Vue驗(yàn)證碼60秒倒計時功能簡單實(shí)例代碼
更新時間:2018年06月22日 16:11:34 作者:Goodbye_Youth
這篇文章主要介紹了Vue驗(yàn)證碼60秒倒計時功能簡單實(shí)例代碼,代碼簡單易懂,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
template
<template> <div class='login'> <div class="loginHeader"> <input type="tel" class="loginBtn border-bottom" placeholder="請輸入手機(jī)號" /> <input type="tel" class="codeBtn" placeholder="請輸入驗(yàn)證碼" /> <input type="button" class="getNumber" v-model="codeMsg" @click="getCode" :disabled="codeDisabled" /> </div> </div> </template>
script
<script>
export default {
data() {
return {
// 是否禁用按鈕
codeDisabled: false,
// 倒計時秒數(shù)
countdown: 60,
// 按鈕上的文字
codeMsg: '獲取驗(yàn)證碼',
// 定時器
timer: null
}
},
methods: {
// 獲取驗(yàn)證碼
getCode() {
// 驗(yàn)證碼60秒倒計時
if (!this.timer) {
this.timer = setInterval(() => {
if (this.countdown > 0 && this.countdown <= 60) {
this.countdown--;
if (this.countdown !== 0) {
this.codeMsg = "重新發(fā)送(" + this.countdown + ")";
} else {
clearInterval(this.timer);
this.codeMsg = "獲取驗(yàn)證碼";
this.countdown = 60;
this.timer = null;
this.codeDisabled = false;
}
}
}, 1000)
}
}
}
}
</script>
css(scss寫法)
<style>
.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;
}
}
}
</style>
總結(jié)
以上所述是小編給大家介紹的Vue驗(yàn)證碼60秒倒計時功能簡單實(shí)例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
您可能感興趣的文章:
- 簡單實(shí)現(xiàn)vue驗(yàn)證碼60秒倒計時功能
- Vue通過for循環(huán)隨機(jī)生成不同的顏色或隨機(jī)數(shù)的實(shí)例
- 基于vue實(shí)現(xiàn)圖片驗(yàn)證碼倒計時60s功能
- Vue實(shí)現(xiàn)手機(jī)號、驗(yàn)證碼登錄(60s禁用倒計時)
- vue組件封裝實(shí)現(xiàn)抽獎隨機(jī)數(shù)
- vue中如何使用唯一標(biāo)識uuid(uuid.v1()-時間戳、uuid.v4()-隨機(jī)數(shù))
- Vue3+Hooks實(shí)現(xiàn)4位隨機(jī)數(shù)和60秒倒計時的示例代碼
相關(guān)文章
vue 的keep-alive緩存功能的實(shí)現(xiàn)
本篇文章主要介紹了vue 的keep-alive緩存功能的實(shí)現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-03
Vue利用mockjs編寫假數(shù)據(jù)并應(yīng)用的問題記錄
這篇文章主要介紹了Vue利用mockjs編寫假數(shù)據(jù)并應(yīng)用,本文通過實(shí)例代碼給大家詳細(xì)講解,對Vue?mockjs數(shù)據(jù)相關(guān)知識感興趣的朋友跟隨小編一起看看吧2022-12-12
利用vue-router實(shí)現(xiàn)二級菜單內(nèi)容轉(zhuǎn)換
這篇文章主要介紹了如何利用vue-router實(shí)現(xiàn)二級菜單內(nèi)容轉(zhuǎn)換,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-11-11
vue+watermark-dom實(shí)現(xiàn)頁面水印效果(示例代碼)
watermark.js 是基于 DOM 對象實(shí)現(xiàn)的 BS 系統(tǒng)的水印,確保系統(tǒng)保密性,安全性,降低數(shù)據(jù)泄密風(fēng)險,簡單輕量,支持多屬性配置,本文將通過 vue 結(jié)合 watermark-dom 庫,教大家實(shí)現(xiàn)簡單而有效的頁面水印效果,感興趣的朋友跟隨小編一起看看吧2024-07-07

