Vue驗(yàn)證碼60秒倒計(jì)時(shí)功能簡(jiǎn)單實(shí)例代碼
template
<template> <div class='login'> <div class="loginHeader"> <input type="tel" class="loginBtn border-bottom" placeholder="請(qǐng)輸入手機(jī)號(hào)" /> <input type="tel" class="codeBtn" placeholder="請(qǐng)輸入驗(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, // 倒計(jì)時(shí)秒數(shù) countdown: 60, // 按鈕上的文字 codeMsg: '獲取驗(yàn)證碼', // 定時(shí)器 timer: null } }, methods: { // 獲取驗(yàn)證碼 getCode() { // 驗(yàn)證碼60秒倒計(jì)時(shí) 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寫(xiě)法)
<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秒倒計(jì)時(shí)功能簡(jiǎn)單實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- 簡(jiǎn)單實(shí)現(xiàn)vue驗(yàn)證碼60秒倒計(jì)時(shí)功能
- Vue通過(guò)for循環(huán)隨機(jī)生成不同的顏色或隨機(jī)數(shù)的實(shí)例
- 基于vue實(shí)現(xiàn)圖片驗(yàn)證碼倒計(jì)時(shí)60s功能
- Vue實(shí)現(xiàn)手機(jī)號(hào)、驗(yàn)證碼登錄(60s禁用倒計(jì)時(shí))
- vue組件封裝實(shí)現(xiàn)抽獎(jiǎng)隨機(jī)數(shù)
- vue中如何使用唯一標(biāo)識(shí)uuid(uuid.v1()-時(shí)間戳、uuid.v4()-隨機(jī)數(shù))
- Vue3+Hooks實(shí)現(xiàn)4位隨機(jī)數(shù)和60秒倒計(jì)時(shí)的示例代碼
相關(guān)文章
Vue?中的?computed?和?watch?的區(qū)別詳解
這篇文章主要介紹了Vue中的computed和watch的區(qū)別詳解,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-09-09vue點(diǎn)擊右鍵出現(xiàn)自定義操作菜單實(shí)現(xiàn)代碼
這篇文章主要給大家介紹了關(guān)于vue點(diǎn)擊右鍵出現(xiàn)自定義操作菜單實(shí)現(xiàn)的相關(guān)資料,在網(wǎng)頁(yè)中我們也希望可以像桌面軟件一樣,點(diǎn)擊右鍵后出現(xiàn)操作菜單,對(duì)選中的數(shù)據(jù)項(xiàng)進(jìn)行相應(yīng)的操作,需要的朋友可以參考下2023-08-08vue2和elementUI?實(shí)現(xiàn)落日余暉登錄頁(yè)和滑塊校驗(yàn)功能
這篇文章主要介紹了vue2和elementUI打造落日余暉登錄頁(yè)和滑塊校驗(yàn),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2023-06-06vue 通過(guò) Prop 向子組件傳遞數(shù)據(jù)的實(shí)現(xiàn)方法
這篇文章主要介紹了vue 通過(guò) Prop 向子組件傳遞數(shù)據(jù)的實(shí)現(xiàn)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10vue項(xiàng)目如何讓局域網(wǎng)ip訪(fǎng)問(wèn)配置設(shè)置
這篇文章主要介紹了vue項(xiàng)目如何讓局域網(wǎng)ip訪(fǎng)問(wèn)配置設(shè)置,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。2022-09-09vue實(shí)現(xiàn)微信分享朋友圈,發(fā)送朋友的示例講解
下面小編就為大家分享一篇vue實(shí)現(xiàn)微信分享朋友圈,發(fā)送朋友的示例講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-02-02Element框架el-tab點(diǎn)擊標(biāo)簽頁(yè)時(shí)再渲染問(wèn)題的解決
本文主要介紹了Element框架el-tab點(diǎn)擊標(biāo)簽頁(yè)時(shí)再渲染問(wèn)題的解決,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-04-04