zoukankan      html  css  js  c++  java
  • 手机浏览器下IScroll中click事件

    产品的h5页面几乎都使用了iscroll插件,如果a标签在iscroll里,在部分手机浏览器中会出现无法点击的情况,不管是绑定click事件还是使用a标签的href属性。href属性偶尔还会能点击,click事件完全不能。

    如果用button或input代替a,都能响应click事件。

    如果用微信内置浏览器,都能响应click事件(nubia除外)。QQ浏览器也能响应。

    也就是出现此问题跟手机本地浏览器,iscroll,a标签都有关系。

    iScroll uses various techniques to scroll based on device/browser capability. Normally you don't need to configure the engine, iScroll is smart enough to pick the best for you.

    Nonetheless it is important to understand which mechanisms iScroll works on and how to configure them.

     这里说通常情况下你不需要额外配置iscroll,因为iscroll能默认选择最佳配置。

    options太多,直接看重点,click和tap

    To override the native scrolling iScroll has to inhibit some default browser behaviors, such as mouse clicks. If you want your application to respond to the click event you have to explicitly set this option to true. Please note that it is suggested to use the custom tap event instead (see below).

    原因就是这儿了,iscroll阻止了浏览器默认的行为,比如click。如果设置click为true,原来不能点击的手机能点击了,但是原来能点击的手机变成了双击,也就是将手机本身的click和iscroll的click各执行了一次。

    如果只设置click为true,会出现部分a还是无法点击,再加上taps:true;

    感谢万能的stackoverflow, 

  • 相关阅读:
    Codeforces 938G(cdq分治+可撤销并查集+线性基)
    codeforces 938F(dp+高维前缀和)
    寒武纪camp Day6
    寒武纪camp Day5
    寒武纪camp Day4
    bzoj4161 (k^2logn求线性递推式)
    loj10003加工生产调度
    loj10002喷水装置
    loj10001种树
    bzoj1023
  • 原文地址:https://www.cnblogs.com/alexandra/p/3968457.html
Copyright © 2011-2022 走看看