Get the App
SLTechnology News&Howtos  ›  Development  › 

What about the program timing shutter in WeChat Mini Programs?

Shulou Source: shulou.com Published: 2022-06-03 06:22:50 11月16日 Update

This article will explain in detail about the program timing shutter in WeChat Mini Programs, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

In the development process of WeChat Mini Programs, we often encounter the use of countdown, but Mini Program page jump will often encounter the next page after the jump, the countdown to the previous page is still running. This requires us to clear the current countdown when we close or leave the current page, but the traditional way can not be used in Mini Program, in Mini Program I use the method of assigning and then clearing.

The traditional way of program timing shutter:

Var myVar = setInterval (function () {myTimer ()}, 1000); function myTimer () {var d = new Date (); var t = d.toLocaleTimeString (); document.getElementById ("demo") [xss_clean] = t;} function myStopFunction () {clearInterval (myVar);}

The program timing lockout is in Mini Program:

Page {data= {myTime:null,} onUnload () {clearInterval (this.myTime);} _ formatSeconds () {/ / countdown initialization; let I = 0, that = this, orignalTime = parseInt (this.timeout) clearInterval (this.myTime); this.myTime = setInterval (()) = > {let theTime = parseInt (that.timeout), / / second let theTime1 = 0mlt / min let theTime2 = 0jue / h theTime3 = 0jue / day

About WeChat Mini Programs in the program timing shutter how to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Program countdown page sequence tradition content regular meeting article way more knowledge article good hour situation method time quality process reference Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker vpn Redmi Huawei Microsoft