|
本帖最后由 442724344 于 2018-5-4 21:39 编辑
最近发现应用在苹果上输入框Input 非常难点中,要点多次或者点的时间要长(大于100ms)才可以点中,关于焦点问题,首先考虑是fastclick.js的问题(当然也不完全是他的错,手机系统升级后,旧的fastclick.js就有可能有没有考虑到的问题);测试发现可能解决办法如下(是否完美还不知道)
最新IOS和fastclick冲突,最新IOS已处理延迟问题,故无需再要fastclick.js,故先修改如下,
找到\model\UI2\system\components\justep\lib\fastclick.js
新增代码=====
var deviceIsIOSVer = 0;
if(deviceIsIOS)
deviceIsIOSVer = parseFloat(navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?) like mac os/)[1].replace(/_/g,"."));
修改代码======
/**
* @param {EventTarget|Element} targetElement
*/
FastClick.prototype.focus = function(targetElement) {
'use strict';
var length;
// Issue #160: on iOS 7, some input elements (e.g. date datetime) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
if (deviceIsIOS && deviceIsIOSVer < 11 && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'number' && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'range') {
length = targetElement.value.length;
targetElement.setSelectionRange(length, length);
} else {
targetElement.focus();
}
};
最后,要合并js,必要的,记住。
|
|