当前位置:网站首页>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
边栏推荐
- Linux数据库Oracle客户端安装,用于shell脚本用sqlplus连接数据库
- The latest and most complete digital collection sales calendar-07.27
- PCL点云配准--ICP or keypoints+features
- pytorch框架学习(2)使用GPU训练
- Database Notes Create Database, Table Backup
- 每天一个小知识点
- Reprint fstream, detailed usage of ifstream
- R中设置图形参数--函数par()详解
- 第二次实验
- 最新最全的数字藏品发售日历-07.26
猜你喜欢
随机推荐
网络安全作业
文章复现:SRCNN
Models corresponding to each architecture instruction set
文本元素
每天一个小知识点
连接 Nacos 报超时错误
Minio分布式存储系统
Mockito基本使用指南
【el和template区别】
2021-06-22
链读|最新最全的数字藏品发售日历-07.29
深度学习中的学习率调整策略(1)
数据库 笔记 创建数据库、表 备份
Module build failed TypeError this.getOptions is not a function报错解决方案
Privatisation build personal network backup NextCloud
第二次实验
链读精选:星巴克着眼于数字收藏品并更好地吸引客户
反射【笔记】
用Pytorch从0到1实现逻辑回归
复杂的“元宇宙”,为您解读,链读APP即将上线!








