WeChat Mini Program API System Information
Get network status——wx.getNetworkType(OBJECT)
WeChat applet gets network type
OBJECT parameter description:
wx.getNetworkType({ success: function (res) { var networkType = res.networkType; // 返回网络类型2g,3g,4g,wifi } });
Get system information——wx.getSystemInfo(OBJECT)
WeChat applet gets system information
success callback parameter description :
##Sample code:
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) } })Listen to the gravity sensor——wx.onAccelerometerChange( CALLBACK)WeChat applet monitors gravity sensing data, frequency: 50 times/second
CALLBACK return parameters:
Sample code:
wx.onAccelerometerChange(function (res) { console.log(res.x) console.log(res.y) console.log(res.z) })Monitoring compass data——wx.onCompassChange(CALLBACK)WeChat applet monitors compass data, frequency : 50 times/second
CALLBACK Return parameters:
Sample code:
wx.onCompassChange(function (res) { console.log(res.direction) })