当前位置:网站首页>Timer (setInterval) on and off
Timer (setInterval) on and off
2022-08-10 05:48:00 【Why can't I get enough to eat?】
The timer I set is turned on when I click to display the subcomponent. After waiting for 30s, I will close the subcomponent without clicking the page. Every time I click on the page, it will be closed without clicking within 30s. When I click to exit the subcomponent page, it will also be closed.will close the timer
// Start the timer when the parent component displays the child componentthis.$refs.manMachine.openOrCloseTime(true)Define the name of the timer and the variable used to count in the subcomponent

// start the timeropenOrCloseTime(isOpen){// When the parent component calls the method, the parameter is passed to decide whether to start the timerif(isOpen==true){timer=setInterval(()=>{this.count--// Turn off the timer when the count variable value becomes 0if(this.count==0){this.close(timer);}},1000)}else{this.close(timer);}},// close the timerclose(timer){clearInterval(timer);// restore the count variable to the initial value for the next usethis.count=30;// Modify the variable value passed from the parent component to control whether the child component is displayed to close the child componentthis.$emit("update:isChat", this.show);},Remember to call the method to close the timer when closing the page
After operating on the page, restore the initial value of the count variable this.count=30, and let the timer re-time
边栏推荐
猜你喜欢

文章复现:SRCNN

matlab中的常用的类型转换

Ten years of sharpening a sword!The digital collection market software, Link Reading APP is officially open for internal testing!

Chained Picks: Starbucks looks at digital collectibles and better engages customers

【格式转换】将JPEG图片批量处理为jpg格式

索引笔记【】【】

【写下自用】每次都忘记如何train?记录如何训练自己的yolov5

.las转.txt 再转.pcd,编译运行中出现的错误

The latest and most complete digital collection sales calendar-07.27

训练集Loss收敛,但是测试集Loss震荡的厉害?
随机推荐
Chain Reading|The latest and most complete digital collection sales calendar-07.29
Small program wx.request simple Promise package
笔记1
图片批量添加水印批量加背景缩放批量合并工具picUnionV4.0
R语言:修改chart.Correlation()函数绘制相关性图——完美出图
图片批量添加水印批量缩放图片到指定大小
Four characteristics of ACID
Operation table Function usage
链读推荐:从瓷砖到生成式 NFT
毫米波雷达基础概念学习
pytorch框架学习(7) tensorboard使用
tinymce富文本编辑器
小记录:Pytorch做深度学习必要加载的包
小程序学习笔记:小程序组件间通信方式
网安超基础一周目
索引笔记【】【】
transaction, storage engine
关于cfar检测的学习及仿真
idm下载器如何使用 idm下载器使用技巧
定时器(setInterval)的开启与关闭