最近自己写了个简单的博客,上面有个计时器。。但是很奇怪这个计时器在电脑端是正常的,发布了体验版用手机看就报错了,因为没有很深入的了解小程序,自己也没有解决。。。知道的麻烦告知下,谢谢~onReady: function(){ var that = this; this.data.intervarID = setInterval(function(){ var date1 = new Date() var date2 = new Date('2016/07/14 00:00:00') var s1 = date1.getTime(), s2 = date2.getTime(); var total = (s1 - s2) / 1000; var day = parseInt(total / (24 * 60 * 60)); var afterDay = total - day * 24 * 60 * 60; var hour = parseInt(afterDay / (60 * 60)); var afterHour = total - day * 24 * 60 * 60 - hour * 60 * 60; var min = parseInt(afterHour / 60); var afterMin = total - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60; var sec = parseInt(afterMin); that.setData({ mytime_d: day, mytime_hour: hour, mytime_min: min, mytime_sec: sec }); }) },
添加回答
举报
0/150
提交
取消