微信小程序當(dāng)在一個(gè)頁面有多個(gè)input輸入框,自動(dòng)彈鍵盤,需要點(diǎn)擊input框2次才能聚焦。
解決辦法,在點(diǎn)擊input框時(shí),調(diào)用bindtap事件,關(guān)閉鍵盤、設(shè)置焦點(diǎn)。代碼示例如下:文章來源:http://www.zghlxwxcb.cn/news/detail-511087.html
<view class="tr">
<view class="th1">
<text class='title text-bold'>賬號(hào):</text>
<input class='radius zc-input text-lg margin-left' bindtap="inputTap" bindinput="bindInputs" id="name" value="{{name}}" placeholder="請(qǐng)輸入賬號(hào)" focus="{{focusId=='name'?true:false}}"></input>
</view>
</view>
<view class="tr">
<view class="th1">
<text class='title text-bold'>密碼:</text>
<input class=' radius zc-input1 text-lg margin-left' type="password" bindtap="inputTap" bindinput="bindInputs" id="password" value="{{password}}" placeholder="請(qǐng)輸入賬號(hào)面膜" focus="{{focusId=='password'?true:false}}"></input>
</view>
</view>
inputTap(e){
var that = this
wx.hideKeyboard()
setTimeout(function(){
that.setData({
focusId: e.currentTarget.id
})
},200)
}
方法僅供參考!文章來源地址http://www.zghlxwxcb.cn/news/detail-511087.html
到了這里,關(guān)于微信小程序當(dāng)在一個(gè)頁面有多個(gè)input輸入框,自動(dòng)彈鍵盤,需要點(diǎn)擊input框2次才能聚焦的問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!