做自(zì)由與創造的先行者

API

小(xiǎo)程序開(kāi)發手冊

爲了(le)讓開(kāi)發者可以很(hěn)方便的調起微信提供的能(néng)力,例如獲取用(yòng)戶信息、微信支付等等,小(xiǎo)程序提供了(le)很(hěn)多 API 給開(kāi)發者去使用(yòng)。

要獲取用(yòng)戶的地理(lǐ)位置時(shí),隻需要:

wx.getLocation({

type: 'wgs84',

success: (res) => {

var latitude = res.latitude // 緯度

var longitude = res.longitude // 經度

}

})

調用(yòng)微信掃一掃能(néng)力,隻需要:

wx.scanCode({

success: (res) => {

console.log(res)

}

})

需要注意的是:多數 API 的回調都是異步,你(nǐ)需要處理(lǐ)好(hǎo)代碼邏輯的異步問題。

網站(zhàn)建設開(kāi)發|APP設計(jì)開(kāi)發|小(xiǎo)程序建設開(kāi)發
下(xià)一篇:小(xiǎo)程序協同工(gōng)作(zuò)和(hé)發布
上(shàng)一篇:組件