倒计时
作者:互联网
countDown(creationTime) { var nowtime = this.serverTime var time1 = creationTime.toString() var date = new Date(time1.replace(/-/g, '/')); var starttime = new Date(date); //定时开始时间 starttime = Date.parse(starttime) var endtime = new Date(starttime + 24 * 60 * 60 * 1000) //定时结束时间 var lefttime = endtime.getTime() - nowtime //当前时间距离结束时间的毫秒数 var showTime='' if (lefttime > 0) { var hh = Math.floor((lefttime / 1000 / 60 / 60) % 24); var mm = Math.floor((lefttime / 1000 / 60) % 60); var ss = Math.floor((lefttime / 1000) % 60); showTime = hh + "小时" + mm + "分" + ss + "秒"; } else{ showTime = ""; } return showTime }, Time: function() { this.timer = setInterval(() => { this.serverTime = new Date() }, 1000); },
还剩{{countDown(item.creationTime)}}结束
标签:lefttime,60,倒计时,Date,var,new,1000 来源: https://www.cnblogs.com/ywky/p/16516201.html