源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

微信小程序 wx.request(object) API详解及实例代码

  • 时间:2020-08-05 15:22 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:微信小程序 wx.request(object) API详解及实例代码
[img]http://files.jb51.net/file_images/article/201609/2016930144942014.gif?201683014500[/img] 这里通过干活集中营的API接口真实请求下数据。如果提示URL 域名不合法,请在 mp 后台配置后重试修改asdebug.js两行代码即可可看下面图 定位到asdebug.js文件 [img]http://files.jb51.net/file_images/article/201609/2016930145058543.png?2016830145111[/img] [b]打开搜索关键字URL 域名不合法关键字就是提示错误信息注释两行代码[/b] [img]http://files.jb51.net/file_images/article/201609/2016930145136610.png?2016830145151[/img] [img]http://files.jb51.net/file_images/article/201609/2016930145202343.png?2016830145217[/img] [b]主要方法:[/b] [img]http://files.jb51.net/file_images/article/201609/2016930145245892.png?201683014535[/img] wxml
<block wx:for-items="{{result}}">
  <view style="width:100%; height: 50rpx"></view>
  <!--index默认为下标,item为每项-->
  <text>第{{index}}条数据 {{item.desc}}</text>
   <text>地址{{item.url}}</text>
</block>
js
Page({
 data:{
  // text:"这是一个页面"
  result: []
 },

 onLoad:function() {
   var that = this; 
   wx.request({
     url: 'http://gank.io/api/data/Android/30/1',
     method: 'GET',
     success:function(res) {
       that.setData({
         result: res.data.results
       })
     }

   })
 },

 listenerButton:function() {


 }

})

感谢阅读此文,希望能帮助到大家,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部