微信小程序api视频课程-网络-wx.request 请求Json对象数据的使用

版权声明:黄菊华 https://blog.csdn.net/u013818205/article/details/88656657

远程数据地址:http://www.hzyaoyi.cn/shuju/02-object.html
内容

{ "id" : 1, "title" : "2018年企业最新代理政策!" }

默认
在这里插入图片描述
点击按钮获取数据后效果
在这里插入图片描述

wxml代码

<button bindtap="myjson">获取远程Json对象数据</button>
返回值:{{jieguo.id}} | {{jieguo.title}}

js代码

 /**
   * 页面的初始数据
   */
  data: {
    jieguo:""
  },
  myjson:function(){
    var that =this;
    wx.request({
      url: 'http://www.hzyaoyi.cn/shuju/02-object.html',
      success:function(res){
        console.log(res.data)
        console.log(res.data.title)
        that.setData({
          jieguo: res.data
        })
      }
    })
  },

欢迎大家收看我的视频教程:微信小程序常用API使用
https://edu.csdn.net/course/detail/16194

网络-wx.request 请求Json对象数据

猜你喜欢

转载自blog.csdn.net/u013818205/article/details/88656657