Implementation examples of common countdown of wechat applet E-commerce

Implementation examples of common countdown of wechat applet E-commerce

Put a text in the wxml file

<text>second: {{second}} micro second:{{micro_second}}</text>

Invoke in JS file

Under the operation verification, go from 10 to 1s, and then display the time.

Therefore, we continue to improve the milliseconds. Note that the step size of milliseconds is limited by the time frequency of the system, so we are accurate to 0.01s, that is, 10ms

js

Wxml file

In this way, when the second level is completed, the millisecond level timer is cleartimeout, and the wordbook is displayed as' micro '_ second too'

Add a countdown4micro method to display the remaining reciprocal in the form of 0:3:19 89

In this way, milliseconds and hours, minutes and seconds run rendering respectively. After reconstruction, the program has better readability. Dateformat is for millisecond operations and does not accept seconds. At the same time, it also saves 100 calculations of 1s

After the above optimization, the amount of code is reduced by half and the operation efficiency is also high.

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>