// 允许从相机和相册扫码
uni.scanCode({
success: function (res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
}
});

- 发布:2022-12-19 10:51
- 更新:2023-02-08 15:36
- 阅读:687
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10
HBuilderX类型: 正式
HBuilderX版本号: 3.6.14
手机系统: iOS
手机系统版本号: iOS 16
手机厂商: 苹果
手机机型: 13pro
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
// 允许从相机和相册扫码
uni.scanCode({
success: function (res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
}
});
// 允许从相机和相册扫码
uni.scanCode({
success: function (res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
}
});
预期结果:
ios手机有反应,出现扫码状态
ios手机有反应,出现扫码状态
实际结果:
扫码界面无反应,黑屏,点击相册 和开启照明都无反应
扫码界面无反应,黑屏,点击相册 和开启照明都无反应
bug描述:
调用扫码apiuni.scanCode({});报错:[JS Framework] Failed to execute the callback function:[ERROR] : [JS Framework] Failed to execute the callback function:TypeError: this.$refs.barcode.cancel is not a function. (In 'this.$refs.barcode.cancel()', 'this.$refs.barcode.cancel' is undefined) __ERROR 页面点击无反应
3 个回复
[已删除]
我也出现了相同的错误
[JS Framework] Failed to execute the callback function:[ERROR] : [JS Framework] Failed to execute the callback function:TypeError: this.$refs.barcode.cancel is not a function. (In 'this.$refs.barcode.cancel()', 'this.$refs.barcode.cancel' is undefined) __ERROR
DCloud_iOS_WZT
看下是否勾选了 barcode 和camera 模块,勾选完需要重新自定义基座
小太阳ing (作者)
之前版本没有勾选,也是正常可用的呀
2022-12-20 10:59
小太阳ing (作者)
之前版本没有勾选,为什么也是正常可用的呀?
2022-12-20 11:12
小太阳ing (作者)
能不能看下iosapp还会出现uni.showToast(OBJECT)无,没反应的问题,已经有人提出了,有解决方案吗?
2022-12-20 12:36
DCloud_iOS_WZT
回复 小太阳ing: 最新版需要勾选,之前会默认打包到基础模块,为了隐私合规需要依赖权限的模块都需要勾选才会打包
2022-12-21 15:29
9***@qq.com
模块勾选了,也重新打包了基座,还是不行,有什么办法吗
2023-02-01 10:34
DCloud_iOS_WZT
回复 9***@qq.com: 你这边什么问题 重新发帖子
2023-02-01 11:59
9***@qq.com
回复 DCloud_iOS_WZT: 和楼主同样的问题,勾选重新打包了也不行,麻烦给看下,谢谢https://ask.dcloud.net.cn/question/162180
2023-02-02 21:49
zhangrl
您好,请问解决了吗