FastClick
ときに、ユーザーがダブルクリックをしているかどうかを確認することで、スクリーン、約300ミリ秒の遅延、上のユーザーがクリックし、デフォルトでは、あなたのモバイルデバイス上のブラウザは、クリックイベントをトリガします。すぐにユーザーのクリックイベントに応答できるようにするには、FastClickがあるでしょう。
インストールfastclickはNPM、コンポーネントとバウアーを使用することができます。また、GEMのRubyのバージョンが提供される Fastclick-レールをと.NETが提供するためにNuGetパッケージ変更は。
npm install fastclick
」からインポートFastClick
fastclick
「;
Vue.use(FastClick)。
// main.jsに導入され、体に結合しています。
'fastclick'からインポートFastClick FastClick.attach(document.body);
ios11.3へのアップグレードの最近の発見後、入力ボックスが鈍感ななりをクリックし、第2のクリックページ入力ボックスが正常に機能するには長押し想起キーボード入力が必要になります。
ソリューション
FastClick.js原文件的
FastClick.prototype.focus
FastClick.prototype.focus = function(targetElement) {
var length;
if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'email') { // 通过 targetElement.setSelectionRange(length, length) 将光标的位置定位在内容的尾部(但注意,这时候还没触发focus事件) length = targetElement.value.length; targetElement.setSelectionRange(length, length);
targetElement.focus();//强制元素focus,即在改写的focus响应函数中直接触发元素的focus事件
} else {
targetElement.focus();
}
};
IOSソフトキーボードページにはリバウンド後にシャットダウンしません(フォーカス、ページ移動のうち、IOS入力を解いた後、質問をクリックすることはできません)
解決策:
var u = navigator.userAgent;
var flag;
var myFunction;
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); if (isIOS) { document.body.addEventListener('focusin', () => { //软键盘弹起事件 flag = true; clearTimeout(myFunction); }) document.body.addEventListener('focusout', () => { //软键盘关闭事件 flag = false; if (!flag) { myFunction = setTimeout(function () { window.scrollTo({ top: 0, left: 0, behavior: "smooth" })//重点 =======当键盘收起的时候让页面回到原始位置(这里的top可以根据你们个人的需求改变,并不一定要回到页面顶部) }, 200); } else { return } }) } else { return }
//フォーカスイベントの入力アウト@ぼかし=「InputBlur」
InputBlur:関数(値){
window.scroll(0、0);
}