wx.createIntersectionObserver()
- 需求的场景描述(希望解决的问题)
Page({
onLoad() {
wx.createIntersectionObserver().relativeToViewport({bottom: 100}).observe('.target-class', (res) => {
res.intersectionRatio // 相交区域占目标节点的布局区域的比例
res.intersectionRect // 相交区域
res.intersectionRect.left // 相交区域的左边界坐标
res.intersectionRect.top // 相交区域的上边界坐标
res.intersectionRect.width // 相交区域的宽度
res.intersectionRect.height // 相交区域的高度
})
}
})
这段代码只有在第一次进入的时候执行,第二次重新进入就不执行了。
很奇怪。求教一下。
- 希望提供的能力
