android - 在 Android 浏览器上使用 Ionic QRScanner 的问题:放大太多
问题描述
我在浏览器的 Ionic 4/Angular 应用程序中使用https://ionicframework.com/docs/native/qr-scanner。
该应用程序在笔记本电脑浏览器上运行良好,并且可以让相机预览和读取 QR 码。
但是,在 Android 浏览器上尝试时,相机放大太多,无法扫描代码。
在互联网上没有太多(只是人们要求将放大/缩小功能添加到插件中),我试图通过另一个插件(https://ionicframework.com/docs/native/camera-preview)控制相机变焦但它没有用。
有谁知道如何解决这个问题?
作为参考,我在此消息的末尾附加了我的代码。
谢谢,
scanCode() {
console.log('entering scan function');
this.qrScanner.prepare()
.then((status: QRScannerStatus) => {
console.log('checking status');
if (status.authorized) {
this.statusScanning=true;
// camera permission was granted
console.log('camera permission granted');
// start scanning
this.scanSub = this.qrScanner.scan().subscribe( (scanRes: string) => {
let object:any=scanRes;
if(isDefined(object.result))
{
let text: string=""+object.result;
this.myfunction(text);
this.qrScanner.hide(); // hide camera preview
this.scanSub.unsubscribe(); // stop scanning
}
});
} else if (status.denied) {
// camera permission was permanently denied
// you must use QRScanner.openSettings() method to guide the user to the settings page
// then they can grant the permission from there
console.log('status denied');
} else {
console.log('permissions denied for now');
// permission was denied, but not permanently. You can ask for permission again at a later time.
}
})
.catch((e: any) => console.log('Error:', e));
}
解决方案
如果有人遇到与我相同的问题,我发现的最佳选择是放弃 QRScanner 组件并使用 jsQR。我遵循了本页教程中的原则(https://devdactic.com/pwa-qr-scanner-ionic/),一切正常。干杯,
推荐阅读
- image-processing - 检查两个人之间相似性的最佳方法是什么?
- css - 如何使用左侧菜单选项使 reactstrap 轮播的尺寸更短?
- powershell - 用于在多个服务器中运行查询的 Powershell 脚本
- javascript - 异步函数抛出错误,我看不到它们
- testing - OpenWrt 中的 Google 测试
- python - 如何用python绘制3d条形图/直方图+颜色?
- svn - SVN 试图提交不存在的文件/文件夹
- java - 使用一致性配置文件 XML 的 HL7 ADT 消息验证
- maven-3 - 将所有具有依赖关系的输出 jar 复制到一个文件夹中
- json - Flutter 获取 JSON 并返回结果