在最近的项目中,发现input输入框 在苹果手机上 点击失效, 需要多次点击才能获取焦点问题,是因为引入了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();
}
};
网友评论