移动端iOS中input聚焦不灵敏(需点击多次)
2019-10-22 本文已影响0人
小西瓜Ly
可能情况1:检查是否使用了FastClick,如果使用了在main.js中增加以下代码即可。
FastClick.attach(document.body);
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();
}
}
可能情况2:App.vue中设置了-webkit-user-select: none;影响到了input,解决方法:
*:not(input,textarea), *:before:not(input,textarea), *:after:not(input,textarea) {
-webkit-user-select: none;
}