一个页面多个定时器,刚接到这个需求的时候,我觉着这不是简简单单,一写下来,懵了
一直在找资料(以我这个才智,找到了也看不懂),某一个时刻突发奇想,搞了个demo,给各位有这个需求的提供个思路
一般开始的时间戳都是后端返回的,这里就是模拟一下
如果后端返回的是 (xxxx-xx-xx xx:xx:xx) 就使用+new Date(xxxx-xx-xx xx:xx:xx)转一下就好
list:[
{
timeA: 1658325600000
},
{
timeA: 1658329200000
},
{
timeA: 1658331494000
},
]
倒计时
我这里 时分秒是分开了,因为我这要分开写一些样式, 没有需求的话,写一起 拼起来就好
setTimeH(starttime) {
let nowTime = +new Date()
let times = (starttime - nowTime) / 1000
let h = Math.floor(times / 60 /60 % 24)
return h < 10 ? '0' + h : h
},
setTimeM(starttime) {