Home > WeChat Applet > Mini Program Development > How does a WeChat applet call a method in a loop?

How does a WeChat applet call a method in a loop?

青灯夜游
Release: 2020-04-12 10:08:06
forward
4203 people have browsed it

How does the WeChat applet call a method in a loop? The following article will introduce to you a method to implement loop calls in WeChat applet. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How does a WeChat applet call a method in a loop?

Implementing a cyclic call to a method in the WeChat applet

If you want to call a method cyclically, you must judge a certain value. This method is called when the value is false. If it is true, it will not be called.

query:function(){
  if(!!wx.getStorageSync('userInfo')){
      let _this=this;
        setTimeout(()=> {
          _this.query();
        },500);
      return;
    }
}
Copy after login

This is a loop calling a method. It can be equipped with a flag to control the maximum number of loops, or write a method after the if. Do it after the loop ends.

Recommendation: " Mini Program Development Tutorial"

The above is the detailed content of How does a WeChat applet call a method in a loop?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template