vue 驗(yàn)證碼界面實(shí)現(xiàn)點(diǎn)擊后標(biāo)灰并設(shè)置div按鈕不可點(diǎn)擊狀態(tài)
1、先看看效果圖
未點(diǎn)擊獲取驗(yàn)證碼的按鈕狀態(tài)
點(diǎn)擊后的不可點(diǎn)擊狀態(tài)
2、代碼實(shí)現(xiàn)
<template> <div class="my-code"> <input class="my-code-input" type="text" v-model="login_form.captcha" placeholder="Your Captcha"> <div class="my-code-get" @click="get_captcha" id="new_yan"> <span v-show="show">Get Captcha</span> <span v-show="!show">{{ count }} s</span> </div> </div> </template> <script> import store from '@/store' import Vue from 'vue' import $ from 'jquery' export default { name: "register", data () { return { show: true, count: 60, timer: null, } }, methods: { get_captcha() { if (this.login_form.username === '' ) { alert('Phone number or mailbox cannot be empty') } else { if(this.timer == null){ getValidate(this.login_form.username).then(response => { const data = response.data console.log(data) console.log('成功') }).catch(error => { console.log(error) alert(error) }) } if (!this.timer) { this.count = 60; this.show = false; $(".my-code-get").addClass("huise") // 將鼠標(biāo)設(shè)置為不可點(diǎn)擊狀態(tài) document.getElementById('new_yan').style.cursor = 'not-allowed' this.timer = setInterval(() => { if (this.count > 0 && this.count <= 60) { this.count-- } else { this.show = true clearInterval(this.timer) this.timer = null } }, 1000) } } } }, created: function() { }, watch:{ timer: function(val){ console.log(val) if(val == null){ // 監(jiān)聽timer變化,移除不可點(diǎn)擊樣式 $(".my-code-get").removeClass("huise") document.getElementById('new_yan').style.cursor = 'pointer' } } } } </script> <style scoped> .my-input{ text-align: left; display: block; width: 400px; height: 35px; padding: 3px; margin: 20px calc(50% - 200px) 20px calc(50% - 200px); background:none; outline:none; border:0px; border-bottom: 2px solid #dcdcdc; border-bottom-left-radius: 1px; border-bottom-right-radius: 1px; box-sizing: border-box; font-family: PingFangSC-Regular; font-size: 16px; } .my-code{ overflow: hidden; } .my-code-get{ float: left; width: 120px; height: 35px; background-color: rgb(7, 187, 127); margin: 0 auto 20px 0; line-height: 35px; font-family: PingFangSC-Regular; color: #ffffff; border-radius: 5px; -webkit-user-select:none; -moz-user-select:none; -ms-user-select:none; user-select:none; } .my-code-get:active{ background-color: #0F996B; } .my-code-get:hover{ cursor: pointer; } .my-code-input{ float: left; text-align: left; display: block; width: 280px; height: 35px; padding: 3px; margin: 0 auto 20px calc(50% - 200px); background:none; outline:none; border:0px; border-bottom: 2px solid #dcdcdc; border-bottom-left-radius: 1px; border-bottom-right-radius: 1px; box-sizing: border-box; font-family: PingFangSC-Regular; font-size: 16px; } .my-code-input:focus{ border-bottom: 2px solid #0F996B; border-bottom-left-radius: 1px; border-bottom-right-radius: 1px; } .huise{ background-color: #dcdcdc !important; color: black; } </style>
以上這篇vue 驗(yàn)證碼界面實(shí)現(xiàn)點(diǎn)擊后標(biāo)灰并設(shè)置div按鈕不可點(diǎn)擊狀態(tài)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- vue3.0實(shí)現(xiàn)點(diǎn)擊切換驗(yàn)證碼(組件)及校驗(yàn)
- Go+Vue開發(fā)一個(gè)線上外賣應(yīng)用的流程(用戶名密碼和圖形驗(yàn)證碼)
- vue實(shí)現(xiàn)一個(gè)6個(gè)輸入框的驗(yàn)證碼輸入組件功能的實(shí)例代碼
- vue實(shí)現(xiàn)短信驗(yàn)證碼輸入框
- Vue插件之滑動(dòng)驗(yàn)證碼用法詳解
- Vue 實(shí)現(xiàn)登錄界面驗(yàn)證碼功能
- vue實(shí)現(xiàn)隨機(jī)驗(yàn)證碼功能(完整代碼)
- vue實(shí)現(xiàn)短信驗(yàn)證碼登錄功能(流程詳解)
- Vue實(shí)現(xiàn)驗(yàn)證碼功能
- VUE實(shí)現(xiàn)圖片驗(yàn)證碼功能
- vue實(shí)現(xiàn)倒計(jì)時(shí)獲取驗(yàn)證碼效果
- Vue如何實(shí)現(xiàn)驗(yàn)證碼輸入交互
相關(guān)文章
vue+layui實(shí)現(xiàn)select動(dòng)態(tài)加載后臺數(shù)據(jù)的例子
今天小編就為大家分享一篇vue+layui實(shí)現(xiàn)select動(dòng)態(tài)加載后臺數(shù)據(jù)的例子,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09詳解如何在vue項(xiàng)目中使用eslint+prettier格式化代碼
在開發(fā)中我們需要一種能夠統(tǒng)一團(tuán)隊(duì)代碼風(fēng)格的工具,作為強(qiáng)制性的規(guī)范,統(tǒng)一整個(gè)項(xiàng)目的代碼風(fēng)格,這篇文章主要介紹了詳解如何在vue項(xiàng)目中使用eslint+prettier格式化代碼,需要的朋友可以參考下2018-11-11Vuex的插件vuex-persistedstate數(shù)據(jù)持久化存儲(chǔ)操作
這篇文章主要介紹了Vuex的插件vuex-persistedstate數(shù)據(jù)持久化存儲(chǔ)操作,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2023-12-12Vue3實(shí)現(xiàn)刷新頁面局部內(nèi)容的示例代碼
本文主要介紹了Vue3實(shí)現(xiàn)刷新頁面局部內(nèi)容的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-07-07vue項(xiàng)目展示pdf文件的方法實(shí)現(xiàn)
本文主要介紹了vue項(xiàng)目展示pdf文件的方法實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07