<button type="primary" bindtap="getNetWorkType">获取网络类型</button>
<button type="primary" bindtap="getSystemInfo">获取设备信息</button>
<button type="primary" bindtap="onAccelerometerChange">监听重力感应数据</button>
<button type="primary" bindtap="onCompassChange">监听罗盘数据</button>
js
Page({
data:{
text:"Page system"
},
onLoad:function(options){
// 页面初始化 options为页面跳转所带来的参数
},
/**
* 获取当前网络状态
*/
getNetWorkType: function() {
wx.getNetworkType({
success: function(res) {
console.log(res)
}
})
},
/**
* 获取系统信息
*/
getSystemInfo: function() {
wx.getSystemInfo({
success: function(res) {
console.log(res)
}
})
},
/**
* 监听重力感应数据
* - 带on开头的都是监听接收一个callback
*/
onAccelerometerChange: function() {
wx.onAccelerometerChange(function(res) {
console.log(res)
})
},
/**
* 监听罗盘数据
*/
onCompassChange: function() {
wx.onCompassChange(function(res) {
console.log(res)
})
},
onReady:function(){
// 页面渲染完成
},
onShow:function(){
// 页面显示
},
onHide:function(){
// 页面隐藏
},
onUnload:function(){
// 页面关闭
}
})API
2022-06-15 128API是开发中必备知识点,合理的应用API可以大大节省开发成本,为您整理收集了包含API接口的信息,包含API接口,API代码,API源码,助你更快的学习使用API技术....
- 带五套模板的API接口系统源码 [2024-01-18]
- layui框架API接口调用管理系统源码 [2024-01-16]
- 小西瓜API管理系统源码2.0 [2023-12-07]
- ApiDebug在线api接口调试浏览器插件 [2023-12-07]
- 抖音短视频去水印官方API接口源码 [2023-10-04]


