title: Taro.onAccelerometerChange(callback)
sidebar_label: onAccelerometerChange
监听加速度数据,频率:5次/秒,接口调用后会自动开始监听,可使用 Taro.stopAccelerometer 停止监听。
支持情况:
.default})
类型
(callback: Callback) => void
参数
| 参数 | 类型 |
|---|---|
| callback | Callback |
Callback
(res: Result) => void
| 参数 | 类型 |
|---|---|
| res | Result |
Result
| 参数 | 类型 | 说明 |
|---|---|---|
| x | number |
X 轴 |
| y | number |
Y 轴 |
| z | number |
Z 轴 |
示例代码
Taro.onAccelerometerChange(res => {console.log(res.x)console.log(res.y)console.log(res.z)})
