WeChat アプレット開発ドキュメント
/ 微信小程序API 系統(tǒng)信息
微信小程序API 系統(tǒng)信息
獲取網(wǎng)絡(luò)狀態(tài)——wx.getNetworkType(OBJECT)
微信小程序獲取網(wǎng)絡(luò)類型
OBJECT參數(shù)說明:
wx.getNetworkType({ success: function (res) { var networkType = res.networkType; // 返回網(wǎng)絡(luò)類型2g,3g,4g,wifi } });
獲取系統(tǒng)信息——wx.getSystemInfo(OBJECT)
微信小程序獲取系統(tǒng)信息
success回調(diào)參數(shù)說明:
示例代碼:
wx.getSystemInfo({ success:function(res){ console.log(res.model) console.log(res.pixelRatio) console.log(res.windowWidth) console.log(res.windowHeight) console.log(res.language) console.log(res.version) } })
監(jiān)聽重力感應(yīng)——wx.onAccelerometerChange(CALLBACK)
微信小程序監(jiān)聽重力感應(yīng)數(shù)據(jù),頻率:50次/秒
CALLBACK返回參數(shù):
示例代碼:
wx.onAccelerometerChange(function (res) { console.log(res.x) console.log(res.y) console.log(res.z) })
監(jiān)聽羅盤數(shù)據(jù)——wx.onCompassChange(CALLBACK)
微信小程序監(jiān)聽羅盤數(shù)據(jù),頻率:50次/秒
CALLBACK返回參數(shù):
示例代碼:
wx.onCompassChange(function (res) { console.log(res.direction) })