var d=10
countDown(d,function(d,h,m,s){
d1.innerHTML="
"+d+"天"+h+"时:"+m+"分:"+s+"秒
"})
functioncountDown(d1, call) {
var that=this;
var time=newDate()
var time1=time.getTime() + d1*1000
var time2=newDate().getTime();
var s=time1-time2;
if(s>0) {
var setitem=setInterval(function() {
var time2=newDate().getTime();
var t=time1-time2;
if(t>0) {
var d=Math.floor(t/1000/60/60/24),
h=Math.floor(t/1000/60/60%24),
m=Math.floor(t/1000/60%60),
s=Math.floor(t/1000%60);
d=that.tosub(d);
h=that.tosub(h);
m=that.tosub(m);
s=that.tosub(s);
call(d,h,m,s)
}else{
clearInterval(setitem)
return
}
},1000)
// that.setData({
// setitem: setitem
// })
}
}
//修改时间的双数问题
functiontosub(d) {
if(d >9) {
d = d.toString()
returnd;
}else{
d = d.toString()
var h1='0',
h2= d;
d =h1+h2
returnd;
}
}
网友评论