版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/themagickeyjianan/article/details/88691419
timeToFormat: function(times){
var hour = "";
var minute = "";
var second = "";
if(times > 0){
hour = Math.floor(times / 3600);
if(hour < 10){
hour = "0" + hour;
}
minute = Math.floor((times - 3600 * hour) / 60);
if(minute < 10){
minute = "0" + minute;
}
second = Math.floor((times - 3600 * hour - 60 * minute) % 60);
if(second < 10){
second = "0" + second;
}
}
return { h: hour, m: minute, s: second };
},
startTime: function(){
this.endTime();
var self = this;
this.lbl_time.string = "00:00s";
var time = 0;
this.timeCallback = function () {
time++;
var t = self.timeToFormat(time);
self.lbl_time.string = t.m + ":" + t.s + "s";
}
this.schedule(this.timeCallback, 1);
},
endTime: function(){
if(this.timeCallback){
this.unschedule(this.timeCallback);
this.timeCallback = null;
}
},