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)聽(tīng)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)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- vue3.0實(shí)現(xiàn)點(diǎn)擊切換驗(yàn)證碼(組件)及校驗(yàn)
- Go+Vue開(kāi)發(fā)一個(gè)線上外賣(mài)應(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.js頁(yè)面驗(yàn)證跳轉(zhuǎn)功能實(shí)現(xiàn)
這篇文章主要介紹了Vue.js頁(yè)面驗(yàn)證跳轉(zhuǎn)功能實(shí)現(xiàn),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧2024-04-04
vue使用iview的modal彈窗嵌套modal出現(xiàn)格式錯(cuò)誤的解決
這篇文章主要介紹了vue使用iview的modal彈窗嵌套modal出現(xiàn)格式錯(cuò)誤的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09
vue中利用simplemde實(shí)現(xiàn)markdown編輯器(增加圖片上傳功能)
這篇文章主要介紹了vue中利用simplemde實(shí)現(xiàn)markdown編輯器(增加圖片上傳功能),本文通過(guò)實(shí)例代碼相結(jié)合的形式給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-04-04
webpack vue 項(xiàng)目打包生成的文件,資源文件報(bào)404問(wèn)題的修復(fù)方法(總結(jié)篇)
這篇文章主要介紹了解決webpack vue 項(xiàng)目打包生成的文件,資源文件報(bào)404問(wèn)題的修復(fù)方法,需要的朋友可以參考下2018-01-01
webpack4+express+mongodb+vue實(shí)現(xiàn)增刪改查的示例
這篇文章主要介紹了webpack4+express+mongodb+vue 實(shí)現(xiàn)增刪改查的示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-11-11

