Joke Collection Website - Blessing messages - How to count down in WeChat text?

How to count down in WeChat text?

1, the first step is to use setInterval directly, but in WeChat applet, you need to use the grammar of WeChat applet, and then you will encounter a problem, that is, how to turn off the timer. An example is given below. WXML code

2. Then, the following is the js implementation code // indes.js needs a target date. When initializing, first, find out how many seconds are left in the current time, and then convert the seconds into print format to provide XX days, XX hours, XX minutes and XX seconds clocks. At this time, it runs once every 10ms to render the clock, and then the total number of ms is reduced by 10, and it returns when the remaining seconds are zero.

3. The function date format (micro _ second) will be called once every 10ms {/totalsecond var second = math.floor (micro _ second/1000); //var day = math . floor(second/3600/24).

4. Finally, the millisecond step is limited by the time frequency of the system, so we are accurate to 0.0 1s, that is, 10ms }/ time printing format, such as 23:00 1, 12 minutes, 12 seconds every day.