微信二维码
微博二维码
qq号二维码

微信小程序之wx.request

夏磊银 2019.11.30 2316人浏览
微信小程序wx.request

wx.request(Object object)

发起 HTTPS 网络请求

参数:

url:开发者服务器接口地址

data:请求的参数

header:设置请求的 header,header 中不能设置 Referer。content-type:application/json

method:HTTP 请求方法

dataType:返回的数据格式

responseType:响应的数据类型1.7.0

success:接口调用成功的回调函数

fail:接口调用失败的回调函数

complete:接口调用结束的回调函数(调用成功、失败都会执行)


最终发送给服务器的数据是 String 类型,如果传入的 data 不是 String 类型,会被转换成 String 。


实例

wx.request({

  url: 'test.php',

  data: {

    x: '',

    y: ''

  },

  header: {

    'content-type': 'application/json'

  },

  success (res) {

    console.log(res.data)

  }

})


分享到:
天津UI设计培训-CleanPNG免抠素材网站
  • 2020.11.30
  • 2024什么价格?天津平面设计/UI设计师就业实录
  • 2024.03.20