WeChat applet example: how to obtain and render data (with code)

不言
Release: 2018-08-16 17:50:35
Original
4699 people have browsed it

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){}
})
Copy after login

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) {
        //失败执行
      }
    })    
}
Copy after login

Page rendering:

<block wx:for="{{shuju}}">
    <view>{{item.xxx}}</view>
</block>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template