【2025年1月2日】关于腾讯云小程序平台更名为腾讯云超级应用服务的公告
控制台更新动态
Android SDK 更新动态
iOS SDK 更新动态
Flutter 更新动态
IDE 更新动态
基础库更新动态
该 API 使用方法为 wx.startCompass(Object object)
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
wx.startCompass()
该 API 使用方法为 wx.stopCompass(Object object)
属性 | 类型 | 默认值 | 必填 | 说明 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
wx.stopCompass()
该 API 使用方法为 wx.onCompassChange(function listener)
属性 | 类型 | 说明 |
direction | number | 面对的方向度数 |
accuracy | number/string | 精度 |
wx.onCompassChange(function (res) {console.log(res.direction)})
值 | 说明 |
high | 高精度 |
medium | 中等精度 |
low | 低精度 |
no-contact | 不可信,传感器失去连接 |
unreliable | 不可信,原因未知 |
unknow ${value} | 未知的精度枚举值,即该 Android 系统此时返回的表示精度的 value 不是一个标准的精度枚举值 |
该 API 使用方法为 wx.offCompassChange(function listener)
const listener = function (res) { console.log(res) }wx.onCompassChange(listener)wx.offCompassChange(listener) // 需传入与监听时同一个的函数对象
文档反馈