先描述一下我遇到的问题:是一个.catch捕捉错误,点击确定返回上一页的问题其中用到了计时器然后,问题就来了,点击返回之后,计时器停止不了,哭泣showCourses() { getCommondityList( this.page, this.pageSize, changeSchoolRegionId, this.industryId ).then(res => { this.pageTotal = res.data.pageTotal; this.courseList = res.data.list; }).catch(err => { this.countNumber++; if (this.countNumber >= 3) { wx.showModal({ title: ‘提示’, content: ‘网络异常,请稍后重试’, showCancel: false, success(res) { if (res.confirm) { wx.navigateBack({ delta: 1 }); } } }) } else { setTimeout(() => { this.showCourses(); }, 1000); } }); }然后我想到了生命周期,onUnload停不下来的原因是因为计时器的问题,然后我在页面返回之后,清除了计时器的时间先赋值this.timer = setTimeout(() => { this.showCourses(); }, 1000);然后在onUnload() { clearTimeout(this.timer); }也就是页面跳转,销毁本页面内容的时候,清除计时器,然后就可以了,哭泣微信小程序
微信小程序返回上一页计时器停止不了的问题
未经允许不得转载:E企盈小程序开发-热线:4006-838-530 » 微信小程序返回上一页计时器停止不了的问题
最新评论
不错的小程序案例
优秀的团队,不错的服务!
讲的很好
主播长的帅气
好系统好服务
优秀的团队
好服务,值得信赖
不错的服务