zoukankan      html  css  js  c++  java
  • 苹果手机focus没有效果 键盘跳不出来


    原因:

    In iOS, Safari is now apparently remembering that the element was focussed but not actually focussing it until a touch down event.
    It is then blindly sending a click event to whichever element received the touch up.
    在IOS中只有用户主动触发的事件才能使focus生效,所以可以在focus之前的用户触发的事件中用focus()方法

    比如VUE中 HTML:
    <p id="click-ele">点击评论</p>
    <input id="input" v-show="isInputShow" type="text"></input>

    js如下:
    document.getElementByID('click-ele').addEventListener('click',function(){
      vue.isInputShow = true
      document.getElementById('input').focus()

    },false)

    这样点击评论后,input标签可以focus,键盘也会跳出来。

    注意有两点:
    (1)document.getElement要在mounted 即DOM结构渲染好之后用,不然获取不到元素。
    (2)P标签上直接使用VUE中的@click=“handlerClick”事件不能生效,原因暂时未知,用原生事件没问题。
  • 相关阅读:
    程序猿节日快乐!
    Haxe UI框架StablexUI的使用备忘与心得(一)
    sudo fdisk -l
    Win7下硬盘安装fedora17
    盎司
    arm-linux工具
    GSM900TCP/UDP连接
    STC51几种简单的延时函数
    STC51六中中断配置点亮一个LED
    LCD1602小程序
  • 原文地址:https://www.cnblogs.com/bulaliu/p/8965600.html
Copyright © 2011-2022 走看看