最近在写app内嵌套H5页面时候,发现给一个盒子用 $(document).on(‘click’,function(){}) 绑定了点击事件,在点击它的子元素的时候点击事件并不生效。但是在浏览器模拟一切正常。

解决方案:

  • 给需要绑定事件的元素添加一个css cursor: pointer ,事件依然用click事件。
  • .farmGoods{    cursor:pointer; }
  • 第二种解决方案是将click事件替换为touchstart事件,或者click事件与touchstart事件并存。
  • $(document).on("touchstart",".farmGoods",function(){     alert('111'); });$(document).on("click touchstart",".farmGoods",function(){    alert('111'); });

    TAG标签: 微信小程序iframe嵌套页面

    http://www.xiaochengxub.com/read-105272.html