更新记录
1.0.0(2026-02-02)
下载此版本
- 初始版本:鸿蒙握姿检测(holding hand)
平台兼容性
uni-app(4.84)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
| × |
× |
× |
× |
× |
× |
× |
× |
12 |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
小红书小程序 |
快应用-华为 |
快应用-联盟 |
| × |
× |
× |
× |
× |
× |
× |
× |
× |
× |
× |
× |
uni-app x(4.84)
| Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
| × |
× |
× |
× |
12 |
× |
otto-harmony-holding-hand
基于 HarmonyOS Multimodal Awareness Motion 的握姿检测(左手 / 右手 / 双手 / 未握持 / 未识别)。需要 API version 20+。
依赖与权限
- 需要权限:
ohos.permission.DETECT_GESTURE
- 仅在部分机型支持;若不支持,接口会返回错误码 801。
UTS 调用示例(前端页面)
<template>
<view class="page">
<button @click="startListen">开启监听</button>
<button @click="stopListen">stop监听</button>
<button @click="latestValue">最新</button>
</view>
</template>
<script setup lang="ts">
import {
startHoldingHand,
stopHoldingHand,
getLastHoldingHandStatus
} from '@/uni_modules/otto-harmony-holding-hand'
const startListen = () => {
startHoldingHand({
success(res) {
console.log('holding hand:', res.status, res.raw)
},
fail(err) {
console.error('holding hand error:', err.errCode, err.errMsg)
}
})
}
// 需要时停止监听
const stopListen = () => {
stopHoldingHand()
}
// 读取最近一次缓存值(可能为 null)
const latestValue = () => {
const last = getLastHoldingHandStatus()
console.log('last', last)
}
</script>
返回值
status:not_held | left | right | both | unknown
raw:原始枚举值(HarmonyOS HoldingHandStatus)