第三篇、微信小程序-网络请求API
2016-10-22 22:43
453 查看
wx.request(OBJECT)发起的是https请求。一个微信小程序,同时只能有5个网络请求连接。
OBJECT参数说明:
效果图:
net.js
net.wxml:
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>
相关文章推荐
- 微信小程序API之网络(一)发起请求
- 微信小程序 网络请求API详解
- 微信小程序请求网络API 400错误的解决方法
- 微信小程序入门二: 条件、遍历、网络请求、获取本地图片
- 微信小程序网络请求的setDate
- 微信小程序实践(二)网络请求的封装
- 微信小程序的网络请求 —— 微信小程序教程系列(14)
- 微信小程序request请求实例,网络请求。
- 微信小程序——网络请求之关于referer
- 微信小程序 网络请求之设置合法域名
- 微信小程序之wx.request:fail错误,真机预览请求无效问题解决,安卓,ios网络预览异常
- 微信小程序网络请求wx.request请求
- 微信小程序 网络请求(post请求,get请求)
- 微信小程序开发之网络请求(POST请求)
- 微信小程序 网络API Websocket详解
- 微信小程序目录结构、事件处理、网络请求
- 微信小程序网络请求应用->发送参数返回服务器内容
- 微信小程序之网络请求(post)