微信小程序组件中使用 setTimeout 无法清除怎么解决?

发布于 5 年前作者 fanglong5143 次浏览最后编辑 5 年前来自 ask

在小程序组件使用了setTimeout,并且生命周期销毁都设置了清除,但是使用工具体验评分并未生效,依旧提示setTimeout未回收,有没有解决的???组件应该放在哪里回收?

lifetimes: {
    detached() {
      clearTimeout(this.data.setTimer)
    }
},
pageLifetimes: {
    hide() {
      clearTimeout(this.data.setTimer)
    },
    detached() {
      clearTimeout(this.data.setTimer)
    },
 },
1 回复
yuangang
yuangang1 楼2 个月前

提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。