uni.startGyroscope(options?)
开始监听陀螺仪数据。
startGyroscope 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS | HarmonyOS(Vapor) |
| x | 4.41 | 5.08 | 5.08 | 5.08 | 5.08 |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| options | StartGyroscopeOptions | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 | | interval | string | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| | | 合法值 | 兼容性 | 描述 | | game | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | ui | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | normal | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - |
| | success | (res: GyroscopeSuccess) => void | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| | | fail | (res: GyroscopeFail) => void | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| | | complete | (res: string) => void | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
|
GyroscopeSuccess 的属性值
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
| errMsg | string | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
GyroscopeFail 的属性值
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
| errCode | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
| 合法值 | 兼容性 | 描述 | | 501 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 502 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 503 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 504 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 601 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 602 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 603 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 604 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 701 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 702 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 703 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 704 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 801 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 802 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 803 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 804 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 901 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - |
|
| errSubject | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| 统一错误主题(模块)名称 |
| data | any | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| 错误信息中包含的数据 |
| cause | Error | 否 | - | - | 源错误信息,可以包含多个错误,详见SourceError |
| errMsg | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
的属性值
| 合法值 | 兼容性 | 描述 |
| interface | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - |
| interface | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - |
参见
uni.stopGyroscope(options?)
停止监听陀螺仪数据变化事件。
stopGyroscope 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS | HarmonyOS(Vapor) |
| x | 4.41 | 5.08 | 5.08 | 5.08 | 5.08 |
参数
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
| options | StopGyroscopeOptions | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 | | success | (res: GyroscopeSuccess) => void | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| | | fail | (res: GyroscopeFail) => void | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| | | complete | (res: string) => void | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
|
GyroscopeSuccess 的属性值
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
| errMsg | string | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
GyroscopeFail 的属性值
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
| errCode | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
| 合法值 | 兼容性 | 描述 | | 501 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 502 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 503 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 504 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 601 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 602 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 603 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 604 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 701 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 702 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 703 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 704 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 801 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 802 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 803 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 804 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - | | 901 | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - |
|
| errSubject | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| 统一错误主题(模块)名称 |
| data | any | 否 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| 错误信息中包含的数据 |
| cause | Error | 否 | - | - | 源错误信息,可以包含多个错误,详见SourceError |
| errMsg | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
的属性值
| 合法值 | 兼容性 | 描述 |
| interface | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - |
| interface | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| - |
参见
uni.onGyroscopeChange(callback)
监听陀螺仪数据变化事件
支付宝小程序频率为 500ms/次,微信小程序频率根据 uni.startGyroscope 的 interval 参数设置。事件只有在调用 uni.startGyroscope 后才会开始监听,使用 uni.stopGyroscope 可以停止监听。
onGyroscopeChange 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS | HarmonyOS(Vapor) |
| x | 4.41 | 5.08 | 5.08 | 5.08 | 5.08 |
参数
OnGyroscopeChangeCallbackResult 的属性值
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
| x | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
| y | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
| z | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
参见
uni.offGyroscopeChange(callback?)
停止监听陀螺仪数据变化事件
offGyroscopeChange 兼容性
| Web | 微信小程序 | Android | iOS | HarmonyOS | HarmonyOS(Vapor) |
| x | 4.41 | 5.08 | 5.08 | 5.08 | 5.08 |
参数
OnGyroscopeChangeCallbackResult 的属性值
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
| x | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
| y | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
| z | number | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | x | - | - | - | - |
| |
参见
通用类型
GeneralCallbackResult
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
| errMsg | string | 是 | - | |
Web
|
微信小程序
|
Android
|
iOS
|
HarmonyOS
| | - | 4.41 | - | - | - |
| 错误信息 |