倒计时在微信ide上可以用,在手机上测试出了bug
[图片] ide上可以正常倒计时 [图片] 手机扫码预览显示NaN 代码如下 [代码]function[代码] [代码]timer(that, leftTime) {[代码][代码] [代码][代码]// 渲染倒计时时钟[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]countDown: date_format(leftTime)[代码][代码] [代码][代码]});[代码][代码] [代码][代码]if[代码] [代码](leftTime <= 0) {[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]countDown: [代码][代码]'00分00秒'[代码][代码],[代码][代码] [代码][代码]overdue: [代码][代码]true[代码][代码] [代码][代码]});[代码][代码] [代码][代码]// timeout则跳出递归[代码][代码] [代码][代码]return[代码][代码];[代码][代码] [代码][代码]}[代码][代码] [代码][代码]setTimeout([代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]// 放在最后--[代码][代码] [代码][代码]leftTime -= 1;[代码][代码] [代码][代码]timer(that, leftTime);[代码][代码] [代码][代码]}, 1000)[代码][代码]}[代码][代码]function[代码] [代码]date_format(leftTime) {[代码][代码] [代码][代码]// 分钟位[代码][代码] [代码][代码]var[代码] [代码]min = fill_zero_prefix(Math.floor(leftTime / 60));[代码][代码] [代码][代码]// 秒位[代码][代码] [代码][代码]var[代码] [代码]sec = fill_zero_prefix(leftTime % 60);[代码][代码] [代码][代码]return[代码] [代码]min + [代码][代码]'分'[代码] [代码]+ sec + [代码][代码]'秒'[代码][代码];[代码][代码]}[代码][代码]function[代码] [代码]fill_zero_prefix(num) {[代码][代码] [代码][代码]return[代码] [代码]num < 10 ? [代码][代码]"0"[代码] [代码]+ num : num[代码][代码]}[代码]请有做过类似功能的大佬们帮看一下