uniapp小程序24小时倒计时

 1
<view>{{countdown}}</view>

 

 data() {
 2             return {
 3                 h:23,//
 4                 m:59,//
 5                 s:59,//
 6                 countdown:'24:00:00',//倒计时
 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 }

 

posted @ 2020-03-17 17:40  zhangPooo  阅读(3302)  评论(0编辑  收藏  举报