1. 程式人生 > >微信api介面詳解

微信api介面詳解

發起請求  wx.request
wx.request({
  url: 'test.php', //僅為示例,並非真實的介面地址
  data: {
     x: '' ,
     y: ''
  },
  header: {
      'content-type': 'application/json' // 預設值
  },
  success: function(res) {
    console.log(res.data)
  }
})

url  寫跳轉的地址  data 是傳輸的資料  success 成功之後 進行細操作

資料快取 wx.setStorage()

wx.setStorage({
  key:"key",
  data:"value"
})

key  是 檔名

data 是資料

快取讀取 wx.getStoragesync()

括號內 寫快取是的檔名 傳給變數即可