混合開發(fā)過程中破加,iOS引用前端界面之后,界面點(diǎn)擊會(huì)默認(rèn)產(chǎn)生一個(gè)300毫秒的延時(shí)效果雹嗦,為了解決這個(gè)問題范舀,引入fastClick合是,但是當(dāng)界面引入fastClick之后,會(huì)產(chǎn)生輸入框點(diǎn)擊無法獲取焦點(diǎn)問題尿背,只有雙擊或者長(zhǎng)按的時(shí)候才能使input輸入框獲取到焦點(diǎn)端仰,該問題是由于引入fastClick導(dǎo)致的捶惜,解決方案如下:
FastClick.prototype.focus = function(targetElement) {
? var length;
// Issue #160: on iOS 7, some input elements (e.g. date datetime month) 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&& 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();
}
};
再引入fastClick的js中加入如上代碼即可解決input輸入框點(diǎn)擊不能獲取焦點(diǎn)的問題