解決vue js IOS H5focus無(wú)法自動(dòng)彈出鍵盤(pán)的問(wèn)題
IOS不自動(dòng)彈出鍵盤(pán),必須手動(dòng)觸發(fā)一下focus才行,不能自動(dòng)調(diào)用,所以需要誘導(dǎo)用戶點(diǎn)擊某個(gè)按鈕觸發(fā)focus,最終修改的方法,默認(rèn)隱藏密碼輸入框,隱藏不能用v-if或者是v-show,用position:absolute, top:-1000,然后點(diǎn)擊輸入密碼將top改為視窗內(nèi),并且調(diào)用focus的方法
代碼如下,有問(wèn)題歡迎評(píng)論
<template>
<div class="pwdpush-box">
<h4 class="enter-password" @click="enterPwd">輸入密碼</h4>
<div class="phonenum-show" :class="pushShow?'':'write-phonenum-1000'">
<div class="write-phonenum">
<p @click.prevent="pushShow = false">使用余額支付 8864</p>
<p>支付密碼:</p>
<ul class="write-input clearfix">
<input type="tel" ref="input" maxlength="6" class="realInput" v-model="realInput" autofocus @keyup="getNum()" v-focus @keydown="delNum()">
<li v-for="disInput in disInputs"><input type="tel" maxlength="1" disabled v-model="disInput.value"></li>
</ul>
<mt-button size="large" style="margin-top:80px;" @click="goPay">確認(rèn)支付</mt-button>
</div>
</div>
</div>
</template>
<script>
import { Field,Toast ,Indicator} from 'mint-ui';
import {headerNav,bottomShow} from '../../vuex/actions/actionDoc'
export default {
name: 'packe',
vuex: {
actions:{
headerNav,
bottomShow
}
},
data(){
return{
messagepacket:false,
packets:[
],
disInputs:[{value:''},{value:''},{value:''},{value:''},{value:''},{value:''}],
realInput:'',
pushShow:false
}
},
mounted(){
this.headerNav(false)
this.bottomShow(false)
},
methods:{
getNum(){
for(var i=0;i<this.realInput.length;i++){
this.disInputs[i].value=this.realInput.charAt(i)
// 表示字符串中某個(gè)位置的數(shù)字,即字符在字符串中的下標(biāo)。
}
},
delNum(){
var oEvent = window.event;
if (oEvent.keyCode == 8) {
if(this.realInput.length>0){
this.disInputs[this.realInput.length-1].value=''
}
}
},
goPay(){
console.log(this.realInput)
},
enterPwd(){
this.pushShow = true;
this.$refs.input.focus()
}
}
}
</script>
<style lang="less" sconed>
.enter-password{
text-align: right;
color:#1D890D;
font-size: 18px;
line-height: 2;
margin-top:20px;
padding-right: 20px;
}
.phonenum-show{
background: rgba(0,0,0,0.6);
position: absolute;
top:0;
right:0;
bottom:0;
left:0;
z-index: -1;
}
.getback-title span{position: absolute;right:0;top:3px;width:15px;height:15px;display: inline-block;}
.write-phonenum-1000{
top:-1000px!important;
}
.write-phonenum{
position: absolute;
top:50%;
margin-top:-100px;
left:0;
right:0;
bottom:0;
z-index: 2;
padding:30px 10px 0;
background: #fff;
}
.write-phonenum p{
font-size: 14px;
margin-left:30px;
line-height:2;
}
.write-phonenum p span{color: #3b90d1;}
.write-input {width:312px; margin:10px auto; position: relative;}
.write-input li{float: left;width:30px;height:30px; margin: 0 10px; border:1px solid #888888;}
.write-input li input{-webkit-appearance: none;-moz-appearance: none;-ms-appearance: none;resize: none;outline: none;border:0;width:30px;line-height: 30px;text-align: center;height: 30px;font-size:16px;}
.write-phonenum .mint-button--default{background: #3b90d1;color:#fff;font-family: "微軟雅黑";font-size: 14px;width:80%;margin:10px auto;}
.realInput{
/* Keyword values */
-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
resize: none;
outline: none;
border: 0;
z-index: 3;
position: absolute;
width: 290px;
height: 30px;
line-height: 30px;
background: none;
display: block;
left: 50%;
margin-left: -145px;
top: 34px;
opacity: 0;
font-size: 0px;
caret-color: #fff;
color: #000;
text-indent: -5em;
font-size: 30px;
top:1px;
}
input[type="tel"]:disabled{background-color: #fff;}
</style>
以上這篇解決vue js IOS H5focus無(wú)法自動(dòng)彈出鍵盤(pán)的問(wèn)題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- 詳解IOS點(diǎn)擊空白處隱藏鍵盤(pán)的幾種方法介紹
- 總結(jié)IOS中隱藏軟鍵盤(pán)的三種方式
- 解決ios模擬器不能彈出鍵盤(pán)問(wèn)題的方法
- iOS應(yīng)用開(kāi)發(fā)中監(jiān)聽(tīng)鍵盤(pán)事件的代碼實(shí)例小結(jié)
- 總結(jié)IOS關(guān)閉鍵盤(pán)/退出鍵盤(pán)的五種方式
- IOS關(guān)閉鍵盤(pán)的方法
- iOS讓軟鍵盤(pán)消失的簡(jiǎn)單方法
- 代碼詳解ios鍵盤(pán)收起問(wèn)題
- iOS 開(kāi)發(fā)之 - 關(guān)閉鍵盤(pán) 退出鍵盤(pán) 的5種方式
- iOS鍵盤(pán)如何添加隱藏鍵盤(pán)功能
相關(guān)文章
iview同時(shí)驗(yàn)證多個(gè)表單問(wèn)題總結(jié)
這篇文章主要介紹了iview同時(shí)驗(yàn)證多個(gè)表單問(wèn)題總結(jié),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-09-09
vue 父組件獲取子組件里面的data數(shù)據(jù)(實(shí)現(xiàn)步驟)
在Vue中,父組件可以通過(guò)`ref`引用子組件,并通過(guò)`$refs`屬性來(lái)訪問(wèn)子組件的數(shù)據(jù),下面分步驟給大家介紹vue 父組件獲取子組件里面的data數(shù)據(jù),感興趣的朋友一起看看吧2024-06-06
vuex新手進(jìn)階篇之改變state?mutations的使用
在vue的項(xiàng)目中不可避免的會(huì)使用到vuex用于數(shù)據(jù)的存儲(chǔ),下面這篇文章主要給大家介紹了關(guān)于vuex新手進(jìn)階篇之改變state?mutations的使用,文中通過(guò)圖文以及實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-10-10
vue項(xiàng)目及axios請(qǐng)求獲取數(shù)據(jù)方式
這篇文章主要介紹了vue項(xiàng)目及axios請(qǐng)求獲取數(shù)據(jù)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08
uniapp實(shí)現(xiàn)webview頁(yè)面關(guān)閉功能的代碼示例
uniapp用web-view打開(kāi)一個(gè)網(wǎng)頁(yè),網(wǎng)頁(yè)中點(diǎn)擊跳轉(zhuǎn)到下一層級(jí)的網(wǎng)頁(yè),一層層深入,點(diǎn)擊返回鍵或者頁(yè)面上方返回按鈕只能一層層往回退,下面這篇文章主要給大家介紹了關(guān)于uniapp實(shí)現(xiàn)webview頁(yè)面關(guān)閉功能的相關(guān)資料,需要的朋友可以參考下2024-03-03
Vue判斷數(shù)組內(nèi)是否存在某一項(xiàng)的兩種方法
這篇文章主要介紹了Vue判斷數(shù)組內(nèi)是否存在某一項(xiàng),今天給大家分享兩種方法,分別是findIndex()和 indexOf()方法,本文結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2023-07-07

