收藏
回答

intersectionObserver.observe在界面隐藏后无效

框架类型 问题类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
小程序 Bug intersectionObserver.observe 微信iOS客户端 iOS 6 2.0.0

- 当前 Bug 的表现(可附上截图)

控制台警告信息 Node "#menu" is not found. Intersection observer will not trigger.


- 预期表现

tabbar页面或栈内页面应该能正常执行createIntersectionObserver相关操作


- 复现路径


- 提供一个最简复现 Demo

request({

    url: 'xxxx',

    success: res => {

       wx.createIntersectionObserver().relativeToViewport({ top: -40 }).observe('#menu', res => {

            this.setData({ menuFixed: !res.intersectionRatio });

       });

    }

})


// 当前页面执行request并在success的callback中使用createIntersectionObserver, 在回包之前如果切换到了其它页面(原页面并未unload), 会报出该错误

回答关注问题邀请回答
收藏
登录 后发表内容