wx.createIntersectionObserver传参不生效
发布于 5 年前 作者 junqian 19292 次浏览 来自 问答
  • wx.createIntersectionObserver
  • 传参 不会监听相交,不传参却能打印 不知道哪里写错了什么的
3 回复
Page({  onLoad: function(){
    wx.createIntersectionObserver(this, {      thresholds: [0.2, 0.5]
    }).relativeTo('.relative-class').relativeToViewport().observe('.target-class', (res) => {
      res.intersectionRatio // 相交区域占目标节点的布局区域的比例
      res.intersectionRect // 相交区域
      res.intersectionRect.left // 相交区域的左边界坐标
      res.intersectionRect.top // 相交区域的上边界坐标
      res.intersectionRect.width // 相交区域的宽度
      res.intersectionRect.height // 相交区域的高度
    })
  }
})

{ selectAll : true } 也不行

{ observeAll : true }

回到顶部