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, 

  • 相关阅读:
    背包问题--动态规划
    day03_13 多分支if语句及作业
    day03_12 缩进介绍
    day03_11 if语句实现猜年龄01
    day03_10 注释及简单的用户输入输出
    day03_09 编码部分历史及文件编码简介
    day03_07 变量的重新赋值01
    day03_06 变量详解
    day03_05 Python程序文件执行和与其他编程语言对比
    day03_04 文件后缀及系统环境变量
  • 原文地址:https://www.cnblogs.com/alexandra/p/3968457.html
Copyright © 2011-2022 走看看