js转换时间倒计时


                        // 转换时间
                        tranformTime(){
                            // console.log(this.a,'444444444')
                                if(this.state=="審核中"){
                                    s=--this.a;
                                }else if(this.state=='已完成'){
                                    s=--this.b;
                                }
                                var t;
                                if(s > -1){
                                    var hour = Math.floor(s/3600);
                                    var min = Math.floor(s/60) % 60;
                                    var sec = s % 60;
                                    if(hour < 10) {
                                        t = '0'+ hour + ":";
                                    } else {
                                        t = hour + ":";
                                    }

                                    if(min < 10){t += "0";}
                                    t += min + ":";
                                    if(sec < 10){t += "0";}
                                    t += sec;
                                }
                                // this.countDownTime1=t;
                                if(this.state=="審核中"){
                                    this.countDownTime=t;
                                    setTimeout(this.tranformTime,1000);
                                }else if(this.state=='已完成'){
                                    this.countDownTime1=t;

                                if(s>0){
                                    setTimeout(this.tranformTime,1000);
                                    document.getElementById('push').style.display='none';
                                    document.getElementById('push1').style.display='inline';
                                }else{
                                    document.getElementById('push1').style.display='none';
                                    document.getElementById('push').style.display='inline';
                                }
                                }

                        },

运行:

猜你喜欢

转载自blog.csdn.net/yang__k/article/details/86211741
今日推荐