Home > Article > Web Front-end > How uniapp requests server data
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.
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.
#2. Then define elements in the template to process the returned results and render the dom elements, as shown in the figure below.
#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
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.
5. On the WeChat applet, we open the corresponding page, open the console and debugging tools to see if there is a request
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.
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!