Home  >  Article  >  WeChat Applet  >  How does a WeChat applet call a method in a loop?

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

青灯夜游
青灯夜游forward
2020-04-12 10:07:384163browse

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;
    }
}

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete