微信小程序:请求

94 阅读1分钟
基本写法
wx.request({
  method:"GET"/"POST"//获取用GET,传用POST
  url: 'example.php', //仅为示例,并非真实的接口地址
  data: {
    x: '',
    y: ''
  },
  header: {
    'content-type': 'application/json' // 默认值
  },
  success (res) {
    console.log(res.data)
  }
})