uniapp小程序24小时倒计时

 1 data() {
 2             return {
 3                 h:23,//
 4                 m:59,//
 5                 s:59,//
 6                 countdown:'2020.03.05',//倒计时
 7                 timer:null,//重复执行
 8         },
 9 onLoad(){
10     this.timer = setInterval(()=>{
11         this.timeCount()
12     },1000)
13 },
14 methods:{
15     //24小时倒计时
16             timeCount(){
17                 --this.s;
18                 if(this.s<0){
19                     --this.m;
20                     this.s=59;
21                 }
22                 if(this.m<0){
23                     --this.h;
24                     this.m=59
25                 }
26                 if(this.h<0){
27                     this.s=0;
28                     this.m=0;
29                 }
30                 this.countdown = this.h+":"+this.m+":"+this.s
31             },
32 }

猜你喜欢

转载自www.cnblogs.com/zhangpooo/p/12512205.html