Home > front end >  For help, WeChat applet loading when loading icon will flash
For help, WeChat applet loading when loading icon will flash

Time:10-05

For help, WeChat applet loading icon will flash when loading, because the two requests are needed, I put the two wx. ShowLoading method in the request, and the timer will also have problems with flashing
 const request=(url, method, data, the header)=& gt; {
Wx. ShowLoading ({
Title: '
});

The return of new Promise ((resolve, reject)=& gt; {
Wx. Request ({
Url: API_BASE_URL + url,
Method: method,
Data: data,
Header: header,
Success (request) {
Resolve (request. Data)
},
Fail (error) {
Reject (error)
},
Complete (aaa) {
//loaded
Var timerName=setTimeout (wx. HideLoading, 500);
}
})
})
};
/* *
* encapsulated FMS reques method
*/
Const frequest=(url, method, data, the header)=& gt; {
Wx. ShowLoading ({
Title: '
});
The return of new Promise ((resolve, reject)=& gt; {
Wx. Request ({
Url: FMS_BASE_URL + url,
Method: method,
Data: data,
Header: {
The content-type: "application/json; Charset=utf-8,
""KeyId" : "3 hrzcnowfolh3wsaaaaubglubhhaz2lsbglvbi5jb20uy24bagmebqyh
"},
Success (request) {
Resolve (request. Data)
},
Fail (error) {
Reject (error)
The console. The log (error);
},
Complete (aaa) {
//loaded
Var timerName=setTimeout (wx. HideLoading, 500);
}
})
})
};

CodePudding user response:

Remove the two functions show hidden in
 
Wx. ShowLoading ({
Title: '
});
Promise. All ([request, frequest]), then (res=& gt; {
Wx. HideLoading
});

Have a try

CodePudding user response:

reference 1st floor XZZFXZ response:
remove the two functions show hidden in
 
Wx. ShowLoading ({
Title: '
});
Promise. All ([request, frequest]), then (res=& gt; {
Wx. HideLoading
});

Try
excuse me this code to which is better?
  • Related