❤ 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)
相关推荐
代码搬运媛4 小时前
Jest 测试框架详解与实现指南
前端
counterxing5 小时前
我把 Codex 里的 Skills 做成了一个 MCP,还支持分享
前端·agent·ai编程
wangqiaowq5 小时前
windows下nginx的安装
linux·服务器·前端
之歆6 小时前
DAY_12JavaScript DOM 完全指南(二):实战与性能篇
开发语言·前端·javascript·ecmascript
发现一只大呆瓜6 小时前
Vite凭什么这么快?3分钟带你彻底搞懂 Vite 热更新的幕后黑手
前端·面试·vite
Maimai108086 小时前
React如何用 @microsoft/fetch-event-source 落地 SSE:比原生 EventSource 更灵活的实时推送方案
前端·javascript·react.js·microsoft·前端框架·reactjs·webassembly
kyriewen8 小时前
产品经理把PRD写成“天书”,我用AI半小时重写了一遍,他当场愣住
前端·ai编程·cursor
humcomm8 小时前
元框架的工作原理详解
前端·前端框架
canonical_entropy8 小时前
Attractor Before Harness: AI 大规模开发的方法论
前端·aigc·ai编程
zhangxingchao9 小时前
多 Agent 架构到底怎么选?从 Claude Agent Teams、Cognition/Devin 到工程落地原则
前端·人工智能·后端