欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序  網絡請求API詳解

 更新時間:2016年10月25日 09:48:59   投稿:lqh  
這篇文章主要介紹了微信小程序 網絡請求API詳解的相關資料,需要的朋友可以參考下

wx.request(OBJECT)發(fā)起的是https請求。一個微信小程序,同時只能有5個網絡請求連接。

OBJECT參數說明:

 效果圖:

 net.js

Page({
 data:{
  result:{},
 },
 onLoad:function(options){
  this.getDate('http://baobab.wandoujia.com/api/v2/feed?num=2');
 },
 /**
  * 網絡請求的函數:接收一個URL參數
  */
 getDate:function(URL){
    var that = this; 
    // 申請一個網絡請求
      wx.request({
    url:URL,
    method:'GET',
   //添加data
   // data: {
   //  x: '',
   //  y: ''
   //  },
   //添加頭信息
   // header: {
   //  'Content-Type': 'application/json'
   // },
    // 請求成功的回調
    success: function(res) {
      that.setData({
        result:res.data
      })
      console.log(res.data)
    }
    })
 },
})

net.wxml:

<block wx:for-items="{{result.issueList}}">
  <Text style="color:green;">第{{index+1}}個列表</Text>
  <block wx:for-items="{{item.itemList}}">
     <image style="width:100%;height:200px;" src="{{item.data.cover.feed}}"></image>
  </block>
</block>

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關文章

最新評論