Realize the countdown function
Go straight to code
CountDown: function (time) { var date2 var date1 var self = this window.requestAnimationFrame(step) function step() { date1 = new Date().getTime(); If (date2 == undefined) {date2 = new Date().getTime() + time; } var date3 = date2-date1; Var days = math.floor (date3 / (24 * 3600 * 1000)) var leave1 = date3 % (24 * 3600 * 1000) Var hours = self.zerofill (math.floor (leave1 / (3600 * 1000))) var leave2 = leave1 % (3600 * 1000 Var minutes = self.zerofill (math.floor (leave2 / (60 * 1000))) var leave3 = leave2 % (60 * 60 Var seconds = self.zerofill (math.round (leave3/1000)) let temptime = self.time = days + "days" + If (temptime == 1 hour 00 hour 00 minute 00 seconds) {self.time = '24 hour 00 minute 00 seconds'} else {self.time = '24 hour 00 minute 00 seconds' self.time = temptime.substring(temptime.length - 11, temptime.length) } if (self.time.substring(9, 10) == 0 && self.time.substring(8, 9) == 6) { self.timeObj.sOne = 9 self.timeObj.sTwo = 5 } else { self.timeObj.sOne = self.time.substring(9, 10) self.timeObj.sTwo = self.time.substring(8, 9) } self.timeObj.mOne = self.time.substring(5, 6) self.timeObj.mTwo = self.time.substring(4, 5) self.timeObj.hOne = self.time.substring(1, 2) self.timeObj.hTwo = self.time.substring(0, (1) if the self. Time = = '00 00 00 hours minutes seconds') {the console. The log ()' to 'return} else {window. RequestAnimationFrame (step)}}}, zeroFill: Function (num) {num = "+ num if (num. Length == 1) {num = '0' + num} return num} This. countDown(86400000) // Time initializationCopy the code
Write more sloppy, have a question to contact me.