Home  >  Article  >  Web Front-end  >  How to set up synchronization and asynchronousness in uniapp

How to set up synchronization and asynchronousness in uniapp

coldplay.xixi
coldplay.xixiOriginal
2020-12-09 17:02:5915290browse

Uniapp sets up synchronous and asynchronous methods: first open Hbuilder to create a new default template of uni-app, and use request to make a request; then use async with await, and return Promise in the calling method; finally after execution, you will see request becomes a synchronous request.

How to set up synchronization and asynchronousness in uniapp

The operating environment of this tutorial: windows7 system, uni-app2.5.1 version, thinkpad t480 computer.

Recommended (free): uni-app development tutorial

Uniapp settings synchronous and asynchronous methods:

1. First open Hbuilder and create a new default template of uni-app, as shown in the figure below

How to set up synchronization and asynchronousness in uniapp

2. Then use request Make a request, as shown in the figure below

How to set up synchronization and asynchronousness in uniapp

3. After running, you can see that the following statement is executed before the request is completed, as shown in the figure below

How to set up synchronization and asynchronousness in uniapp

4. Then we use async with await, and then return Promise in the calling method, as shown in the figure below

How to set up synchronization and asynchronousness in uniapp

5. After execution You will see that the request becomes a synchronous request, as shown in the figure below

How to set up synchronization and asynchronousness in uniapp

##6. In addition, when the number of calls increases, you need to increase async and await step by step. As shown in the figure below

How to set up synchronization and asynchronousness in uniapp

#7. After the final execution, you can see that the request request has been completed, and the following two operations will continue, as shown in the figure below

How to set up synchronization and asynchronousness in uniapp

Related free learning recommendations: Programming Video

The above is the detailed content of How to set up synchronization and asynchronousness in uniapp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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

Related articles

See more