请问这个问题最后是怎么解决的呢
倒计时在安卓机上为什么无法正常显示?countdown(timestamp) { let self = this; let timer = setInterval(function () { let nowTime = new Date(); let endTime = new Date(timestamp * 1000); let t = endTime.getTime() - nowTime.getTime(); if (t > 0) { self.setData({ showEnd: false }) let day = Math.floor(t / 86400000); let hour = Math.floor((t / 3600000) % 24); let min = Math.floor((t / 60000) % 60); let sec = Math.floor((t / 1000) % 60); hour = hour < 10 ? '0' + hour : hour; min = min < 10 ? '0' + min : min; sec = sec < 10 ? '0' + sec : sec; if (day > 0) { self.setData({ day: day, hour: hour, min: min, sec: sec, }); } if (day <= 0 && hour > 0) { self.setData({ day: 0, hour: hour, min: min, sec: sec, }); } if (day <= 0 && hour <= 0) { self.setData({ hour: '00', min: min, sec: sec, }); } } else { self.setData({ showEnd: true }) clearInterval(timer); } }, 1000); }, },
2021-04-08请问这个问题最后是怎么解决的呢
setInterval, setTimeout在某些安卓机上无效在页面实现一个简单的倒计时功能,使用setInterval和setTimeout在安卓机上,都无法倒计时。目前ios手机没发现问题。
2021-04-08