Home  >  Article  >  Web Front-end  >  How uniapp requests server data

How uniapp requests server data

coldplay.xixi
coldplay.xixiOriginal
2020-12-14 14:04:257245browse

Uniapp's method of requesting server data: first define a list and define elements in the template; then add methods in methods and use the [uni.request] method to request background data. The URL address is spliced. method, the returned result data is processed in the success function.

How uniapp requests server data

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

Uniapp's method of requesting server data:

1. First define a list in a variable to return the results of background request data, defined as an array type.

How uniapp requests server data

#2. Then define elements in the template to process the returned results and render the dom elements, as shown in the figure below.

How uniapp requests server data

#3. Add a method in methods and use the uni.request method to request background data. The URL address is spliced ​​and the returned result data is processed in the success function

How uniapp requests server data

Recommended (free): uni-app development tutorial

4. We run the program through the crtl r shortcut key in HBuilderX and choose to use the WeChat applet to simulate the process.

How uniapp requests server data

5. On the WeChat applet, we open the corresponding page, open the console and debugging tools to see if there is a request

How uniapp requests server data

6. Then let’s take a look at the running effect of the WeChat applet. The background results returned in the dom element are rendered in the foreground.

How uniapp requests server data

Related free learning recommendations: php programming (video)

The above is the detailed content of How uniapp requests server data. 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