美文网首页
vue--计时器

vue--计时器

作者: PharkiLL | 来源:发表于2021-04-07 19:23 被阅读0次
    timeCount() {
                // 会议计时
                let tempTime = 0;
                let second = 0;
                let minute = 0;
                let hour = 0; 
                this.timeData = "";
                this.timer = setInterval(() => {
                     tempTime += 1;
                     hour = parseInt(tempTime%3600) ; // 转小时
                     minute = parseInt(tempTime%3600/60); // 转分钟
                     second = parseInt(tempTime%3600%60); // 转秒 
                     // 格式化
                     hour = (hour > 9 ? hour : "0" + hour) + "";
                     minute = (minute > 9 ? minute : "0" + minute) + "";
                     second = (second > 9 ? second : "0" + second) + "";
                     
                     this.timeData = hour + ":" + minute + ":" + second;
                }, 1000); 
            },
    

    相关文章

      网友评论

          本文标题:vue--计时器

          本文链接:https://www.haomeiwen.com/subject/rfaukltx.html