<template>
<view @click="scanCode1">
<uni-icons type="scan" size="24" :color="fontColor"></uni-icons>
</view>
</template>
<script setup>
const scanCode1 = () => {
uni.scanCode({
onlyFromCamera: true,
success: function (res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
}
});
}
</script> - 发布:2026-02-04 11:22
- 更新:2026-02-04 11:23
- 阅读:24
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 26.2
HBuilderX类型: Alpha
HBuilderX版本号: 5.0
手机系统: HarmonyOS NEXT
手机系统版本号: HarmonyOS 6.0.0
手机厂商: 华为
手机机型: Pura 70 Pro
页面类型: vue
vue版本: vue3
打包方式: 离线
项目创建方式: HBuilderX
示例代码:
操作步骤:
点击scanCode1的按钮,看原生日志
点击scanCode1的按钮,看原生日志
预期结果:
有打印条码类型和条码内容
有打印条码类型和条码内容
实际结果:
报错```javascript
11:17:13.189 TypeError: uni.scanCode is not a function
11:17:13.189 at scanCode1 (app-service.js:9350:13)
11:17:13.189 at callWithErrorHandling (noname_6.js:3821:21)
11:17:13.189 at callWithAsyncErrorHandling (noname_6.js:3828:17)
11:17:13.189 at UniElement.invoker (noname_6.js:9776:7)
11:17:13.189 at UniElement.dispatchEvent (noname_6.js:1681:22)
11:17:13.189 at UniPageNode.fireEvent (noname_6.js:19393:14)
11:17:13.189 at onNodeEvent (noname_6.js:20614:16)
11:17:13.189 at noname_6.js:20629:11
11:17:13.189 at Array.forEach (<anonymous>)
11:17:13.189 at onVdSync (noname_6.js:20626:13)
报错```javascript
11:17:13.189 TypeError: uni.scanCode is not a function
11:17:13.189 at scanCode1 (app-service.js:9350:13)
11:17:13.189 at callWithErrorHandling (noname_6.js:3821:21)
11:17:13.189 at callWithAsyncErrorHandling (noname_6.js:3828:17)
11:17:13.189 at UniElement.invoker (noname_6.js:9776:7)
11:17:13.189 at UniElement.dispatchEvent (noname_6.js:1681:22)
11:17:13.189 at UniPageNode.fireEvent (noname_6.js:19393:14)
11:17:13.189 at onNodeEvent (noname_6.js:20614:16)
11:17:13.189 at noname_6.js:20629:11
11:17:13.189 at Array.forEach (<anonymous>)
11:17:13.189 at onVdSync (noname_6.js:20626:13)
bug描述:
报错日志
11:17:13.189 TypeError: uni.scanCode is not a function
11:17:13.189 at scanCode1 (app-service.js:9350:13)
11:17:13.189 at callWithErrorHandling (noname_6.js:3821:21)
11:17:13.189 at callWithAsyncErrorHandling (noname_6.js:3828:17)
11:17:13.189 at UniElement.invoker (noname_6.js:9776:7)
11:17:13.189 at UniElement.dispatchEvent (noname_6.js:1681:22)
11:17:13.189 at UniPageNode.fireEvent (noname_6.js:19393:14)
11:17:13.189 at onNodeEvent (noname_6.js:20614:16)
11:17:13.189 at noname_6.js:20629:11
11:17:13.189 at Array.forEach (<anonymous>)
11:17:13.189 at onVdSync (noname_6.js:20626:13)
1 个回复
Ask小助手 - Ask社区AI助手
作为 DCloud 官方评审人员,对该条 bug 反馈的评审结论如下:
反馈完整性
• 标题、描述、代码示例、复现步骤、预期/实际结果、以及 PC/手机环境、HBuilderX 版本、Vue 版本、设备型号等分类信息均已提供,内容完整。
• 代码示例可直接复制运行,无需额外调整。
• 复现步骤清晰:点击按钮即可触发,官方人员可据此复现。
bug 是否成立
根据知识库 barcode > uni.scanCode(OBJECT) > scanCode 兼容性-2 的说明:
建议与后续处理
• 已向用户说明:当前 HarmonyOS Next 暂未支持 uni.scanCode,请等待后续版本更新。
• 如急需扫码功能,可引导用户到插件市场搜索“扫码”关键词,使用社区提供的 uts 扫码插件作为临时替代:https://ext.dcloud.net.cn/search?q=%E6%89%AB%E7%A0%81&orderBy=Relevance&cat1=8&cat2=81
• 建议用户在后续 HBuilderX 更新日志中关注 “HarmonyOS Next 新增 uni.scanCode 支持” 的说明。
要回复问题请先登录或注册
公告
更多>相关问题