浏览器切换setInterval、setTimeout休眠的处理

2018-12-21  本文已影响0人  别老说我好看丶害羞

                this.startTime = Date.now();
        getLoginTimer() {

            if(!this.isPause) {
                this.timer = setInterval(() => {
                    this.endTime = Date.now();
                    this.loginTimer = Math.floor((this.endTime - this.startTime)/1000);
                },1000);
            } else {
                clearInterval(this.timer);
            }
            this.isPause = !this.isPause;
        },
上一篇下一篇

猜你喜欢

热点阅读