The content of this article is about WeChat applet examples: how to obtain and render data (with code). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
1. Data acquisition:
Note:
1. The server address must be configured with https
2. Configure a legal domain name
3. For local debugging, remember to check
wx.request({ url: '接口地址', data: {}, success: function (res) {}, fail:function(err){} })
2. Data rendering:
js The code is as follows:
onLoad: function (options) { var that=this; wx.request({ url: 'https://xxxxxxx', data: {},--参数 success: function (res) { that.setData({ shuju:res.xxxxx }) }, fail: function (err) { //失败执行 } }) }
Page rendering:
<block wx:for="{{shuju}}"> <view>{{item.xxx}}</view> </block>
Related recommendations:
WeChat applet example: code implementation for form submission
WeChat Mini Program Example: How to get the user’s openid (with code)
The above is the detailed content of WeChat applet example: how to obtain and render data (with code). For more information, please follow other related articles on the PHP Chinese website!