我正在开发一个倒计时网站。
代码工作正常,计时器开始在Firefox和Chrome中完美计数,但在Safari中,数字显示NaN:NaN:NaN
有人有这个问题吗?
我正在使用JS倒计时:http://countdownjs.org/
请遵循以下代码:
指令:
.directive('tempoPercorrido', function($interval){
return {
link: function(scope, element, attrs){
var timeNow = new Date(attrs.tempoPercorrido);
var units = countdown.DAYS | countdown.HOURS | countdown.MINUTES | countdown.SECONDS;
var timespan = countdown(timeNow, null, units, 0, 0);
function updateTme(){
var timespan = countdown(timeNow, null, units, 0, 0);
var dias = timespan.days <= 9 ? '0' + timespan.days.toString() : timespan.days.toString();
var horas = timespan.hours <= 9 ? '0' + timespan.hours.toString() : timespan.hours.toString();
var minutos = timespan.minutes <= 9 ? '0' + timespan.minutes.toString() : timespan.minutes.toString();
var segundos = timespan.seconds <= 9 ? '0' + timespan.seconds.toString() : timespan.seconds.toString();
var contador = '<div class="dias circulo">'+ dias + '</div>'+
'<div class="horas circulo">'+ horas + '</div>'+
'<div class="minutos circulo">'+ minutos + '</div>'+
'<div class="segundos circulo">'+ segundos + '</div>';
//console.log(timespan);
$(element).html(contador);
}
updateTme();
$interval(function(){
updateTme();
}, 1000);
}
}
})
HTML:
<div class="horario_banner" tempo-percorrido="2017-09-15 10:00:00"></div>