❤ vue清除定时器Bug

❤ vue清除定时器Bug

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

问题

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

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

javascript 复制代码
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)
相关推荐
DT——4 小时前
Vite项目中eslint的简单配置
前端·javascript·代码规范
学习ing小白6 小时前
JavaWeb - 5 - 前端工程化
前端·elementui·vue
真的很上进7 小时前
【Git必看系列】—— Git巨好用的神器之git stash篇
java·前端·javascript·数据结构·git·react.js
胖虎哥er7 小时前
Html&Css 基础总结(基础好了才是最能打的)三
前端·css·html
qq_278063717 小时前
css scrollbar-width: none 隐藏默认滚动条
开发语言·前端·javascript
.ccl7 小时前
web开发 之 HTML、CSS、JavaScript、以及JavaScript的高级框架Vue(学习版2)
前端·javascript·vue.js
小徐不会写代码7 小时前
vue 实现tab菜单切换
前端·javascript·vue.js
2301_765347548 小时前
Vue3 Day7-全局组件、指令以及pinia
前端·javascript·vue.js
ch_s_t8 小时前
新峰商城之分类三级联动实现
前端·html
辛-夷8 小时前
VUE面试题(单页应用及其首屏加载速度慢的问题)
前端·javascript·vue.js