這篇文章主要介紹vue中驗(yàn)證碼界面怎么實(shí)現(xiàn)點(diǎn)擊后標(biāo)灰并設(shè)置div按鈕不可點(diǎn)擊狀態(tài),文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)自2013年起,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元靖州做網(wǎng)站,已為上家服務(wù),為靖州各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:028-86922220
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)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)站名稱:vue中驗(yàn)證碼界面怎么實(shí)現(xiàn)點(diǎn)擊后標(biāo)灰并設(shè)置div按鈕不可點(diǎn)擊狀態(tài)
文章分享:http://chinadenli.net/article24/ipchce.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、網(wǎng)站排名、網(wǎng)站內(nèi)鏈、品牌網(wǎng)站設(shè)計(jì)、域名注冊(cè)、外貿(mào)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)