Home  >  Q&A  >  body text

前端 - 如何轻量的解决ios设备 input focus的问题

请教大家一个问题。

因为 ios 设备 input focus 行为 必须由事件触发。 而且好像只能是click事件。
我用 touch事件没办法 focus

document.querySelector('selector').addEventListener('click', function(event){
    (this||delegate.obj).focus();
},false);

我现在用 fastclick 解决了这个问题。 但是 fastclick 太大了。(压缩后还有9-10K)


请教大家, 有什么轻量的解决方案嘛。 即可以解决300ms的延迟问题(实测就50ms) 又不用使用 fastclick.

高洛峰高洛峰2718 days ago353

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 16:30:09

    fastclick is already very small...
    And ontouchstart can't trigger focus?

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 16:30:09

    Generally my solution is to place the input box to the top of the screen after clicking on it

    reply
    0
  • Cancelreply