❤ vue清除定时器Bug

❤ vue清除定时器Bug

页面加载,清除定时器 clearTimeout(intm)

问题

遇见的需求是:webapp 从A页面进入B页面,B页面点击按钮,加载完B页面的加载效果进入c,从C页面返回A页面,仍然显示B页面的加载效果

结果定时器一直无法清除在destory销毁之中。后来反复查找修改无果。多次翻看以后,突然之间发现一个问题,就是加载的页面的窗口我并没有进行隐藏,直接【_this.showTap=false】,解决掉了问题。

timer1 = setInterval(function() {
 if (_this.numsheCount < 100) {                                         _this.numsheCount++;
if (_this.numsheCount >= 0 && _this.numsheCount < 15) {
    _this.text = '努力...';
} else if (_this.numsheCount < 20) {
	_this.text = '正在...';
	} else if (_this.numsheCount < 25) {
		_this.text = '准备分析...';
	} else if (_this.numsheCount < 50) {
		_this.text = '分析中...';
	} else if (_this.numsheCount >= 99) {
		_this.text = '久等了亲,已分析完毕!...';
		}
	} else {
		 clearInterval(timer1)
		 setTimeout(function() {
		_this.localStorage.setItem('xyuid', _this.value);
			_this.$router.push('saogao')
			_this.zhuan = false;
		}, 50)
	 }
	}, 30)

猜你喜欢

转载自blog.csdn.net/weixin_43615570/article/details/131009879
今日推荐