gpt4 book ai didi

cordova-plugins - Ionic cordova-plugin-qrscanner没有相机预览

转载 作者:行者123 更新时间:2023-12-04 09:34:25 26 4
gpt4 key购买 nike

我运行了一个简单的演示以使用cordova-plugin-qrscanner,它可以扫描qrcode,但是没有相机预览。

qrscannerDemo on Github

相关代码重击:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';


import { AndroidPermissions } from '@ionic-native/android-permissions';
import { QRScanner, QRScannerStatus } from '@ionic-native/qr-scanner';

@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {

constructor(public navCtrl: NavController,
public androidPermissions: AndroidPermissions,
public qrScanner: QRScanner) {

}

qrscanner() {

// Optionally request the permission early
this.qrScanner.prepare()
.then((status: QRScannerStatus) => {
if (status.authorized) {
// camera permission was granted
alert('authorized');

// start scanning
let scanSub = this.qrScanner.scan().subscribe((text: string) => {
console.log('Scanned something', text);
alert(text);
this.qrScanner.hide(); // hide camera preview
scanSub.unsubscribe(); // stop scanning
});

this.qrScanner.resumePreview();

// show camera preview
this.qrScanner.show();

// wait for user to scan something, then the observable callback will be called

} else if (status.denied) {
alert('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
} else {
// permission was denied, but not permanently. You can ask for permission again at a later time.
alert('else');
}
})
.catch((e: any) => {
alert('Error is' + e);
});

}

}
<ion-header>
<ion-navbar transparent>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
</ion-header>

<ion-content padding style="background: none transparent;">
<button ion-button (click)="qrscanner()">qrscanner</button>
</ion-content>



我在android上运行ionic项目,然后单击按钮,但没有任何 react ,也没有显示摄像头预览。

我再次测试该项目,发现它可以扫描qrcode并获得结果测试,但没有相机预览。

我搜索了问题,有人说应该将主体和所有元素设置为透明。我尝试但不起作用。

Android. Nothing appears on screen. #35

有人帮忙吗?

最佳答案

在顶级index.html中:

<ion-app style="background: none transparent;"></ion-app>

在相机显示页面的html文件中:
<ion-content style="background: none transparent;">

关于cordova-plugins - Ionic cordova-plugin-qrscanner没有相机预览,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45316875/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com