vue移動端項目在IOS上點擊輸入框 失效, 需要點擊多次 input框BUG

  1. 近期發現項目中關於輸入框在ios上點擊失效,多次點擊纔可以獲取焦點的問題,那麼導致這個問題所在的原因是因爲項目中引入了FastClick 這個是解決移動端延遲300毫秒的優化

當使用FastClick 時,輸入框在ios上點擊輸入調取手機自帶輸入鍵盤不靈敏,有時候甚至點不出來。而安卓上完全沒問題。這個原因是因爲FastClick的點擊穿透。解決方法如下:

const FastClick = require('fastclick')

FastClick.prototype.focus = function (targetElement) { let length; if (targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') { length = targetElement.value.length; targetElement.focus(); targetElement.setSelectionRange(length, length); } else { targetElement.focus(); } };

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章