以前常用解決方法為失去焦點(diǎn)時(shí)芯侥,使用下面方法將滾輪滾到最頂部
window.scrollTo(0,0);
但是對(duì)于頁(yè)面是滾動(dòng)頁(yè)面泊交,輸入框在頁(yè)面下方的頁(yè)面很不友好,輸入完失去焦點(diǎn)后柱查,頁(yè)面就會(huì)滾動(dòng)到頂部廓俭,還需拖拉到地步才可以點(diǎn)擊輸入框下的按鈕
因此,這邊有個(gè)方法:思路是在失去焦點(diǎn)后唉工,將頁(yè)面上下滑動(dòng)一下下研乒,代碼如下:
onBlur(){
/ / 判斷是ios
if (this.$utils.isKyAppIos()) {
var currentPosition,timer;
var speed=1;
timer = setInterval(function(){
currentPosition = document.documentElement.scrollTop || document.body.scrollTop;
currentPosition -= speed;
window.scrollTo(0,currentPosition);//頁(yè)面向上滾動(dòng)
currentPosition += speed;
window.scrollTo(0,currentPosition);//頁(yè)面向下滾動(dòng)
clearInterval(timer);
},100);
// window.scrollTo(0,0);
}
}