企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] > [参考](https://uniapp.dcloud.net.cn/api/system/gyroscope) ## 概述 实例 ``` <template> <view> <button @click="start">开始监听陀螺仪变化</button> <button @click="stop">停止监听陀螺仪变化</button> </view> </template> export default { methods: { start() { uni.onGyroscopeChange((res) => { console.log('gyroData.rotationRate.x = ' + res.x) console.log('gyroData.rotationRate.y = ' + res.y) console.log('gyroData.rotationRate.z = ' + res.z) }); uni.startGyroscope({ interval: "normal", success() { console.log('success') }, fail() { console.log('fail') } }) }, stop(){ uni.stopGyroscope({ success() { console.log('stop success!') }, fail() { console.log('stop fail!') } }) } } } ```