小編這次要給大家分享的是vue怎么實(shí)現(xiàn)輸入框自動(dòng)跳轉(zhuǎn)功能,文章內(nèi)容豐富,感興趣的小伙伴可以來(lái)了解一下,希望大家閱讀完這篇文章之后能夠有所收獲。
為白沙黎族等地區(qū)用戶(hù)提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及白沙黎族網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、白沙黎族網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專(zhuān)業(yè)、用心的態(tài)度為用戶(hù)提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶(hù)的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
<template>
<div class="inputClass">
<div v-for="(item,index) in list" :key="index">
<input v-model="item.value" type="password" class="inputBorder" @keyup="jumpNext($event,index,item.value)"
@keydown="replaceValue(index)">
</div>
</div>
</template>JS:
jumpNext(event, index, val) {
if (!/[0-9]/.test(val)) {
this.list[index].value = "";
this.$message({
type: 'warning',
message: '該密碼僅為數(shù)字'
})
return
}
let flag = document.getElementsByClassName("inputBorder"),
currInput = flag[index],
nextInput = flag[index + 1],
lastInput = flag[index - 1];
if (event.keyCode != 8) {
if (index < (this.list.length - 1)) {
nextInput.focus();
} else {
currInput.blur();
}
} else {
if (index != 0) {
lastInput.focus();
}
}
if (index == 0) {
this.num1 = event.key + ''
} else if (index == 1) {
this.num2 = event.key + ''
} else if (index == 2) {
this.num3 = event.key + ''
} else if (index == 3) {
this.num4 = event.key + ''
} else if (index == 4) {
this.num5 = event.key + ''
} else if (index == 5) {
this.num6 = event.key + ''
}
let str = this.num1 + this.num2 + this.num3 + this.num4 + this.num5 + this.num6
if (str.length == 6) {
let params = str
setUpSVIP(params).then(res => {
// this.superVipVisible = false
}).catch(err => {
// this.superVipVisible = false
this.$message({
type: 'error',
message: '設(shè)置超級(jí)VIP失敗'
})
})
}
},
/*當(dāng)鍵盤(pán)按下的時(shí)候清空原有的數(shù)*/
replaceValue(index) {
this.list[index].value = "";
}CSS:
.inputBorder {
background: #ffffff;
width: 50px;
font-size: 50px;
height: 50px;
margin-left: 0px;
margin-right: 0px;
text-align: center;
border: 1px solid #706969;
}
.inputClass {
margin-top: 31px;
display: flex;
justify-content: center;
}
看完這篇關(guān)于vue怎么實(shí)現(xiàn)輸入框自動(dòng)跳轉(zhuǎn)功能的文章,如果覺(jué)得文章內(nèi)容寫(xiě)得不錯(cuò)的話(huà),可以把它分享出去給更多人看到。
分享題目:vue怎么實(shí)現(xiàn)輸入框自動(dòng)跳轉(zhuǎn)功能
URL網(wǎng)址:http://chinadenli.net/article40/phogho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、全網(wǎng)營(yíng)銷(xiāo)推廣、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站內(nèi)鏈、定制網(wǎng)站、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
網(wǎng)頁(yè)設(shè)計(jì)公司知識(shí)