Javascript 如何使用ionic条形码扫描仪扫描驾照和检索信息上的pdf417条形码?

Javascript 如何使用ionic条形码扫描仪扫描驾照和检索信息上的pdf417条形码?,javascript,android,angular,ionic4,ionic5,Javascript,Android,Angular,Ionic4,Ionic5,这是从条形码中检索到的JSON {“text”:“03451736”,“format”:“UPC_E”,“cancelled”:“false”}在应用程序主模块中添加条形码扫描仪的导入 import { BarcodeScanner, BarcodeScannerOptions } from '@ionic-native/barcode-scanner'; 将其添加到提供者数组中 providers: [ ..... ;;;;; Other providers ;;;;

这是从条形码中检索到的JSON


{“text”:“03451736”,“format”:“UPC_E”,“cancelled”:“false”}

在应用程序主模块中添加条形码扫描仪的导入

import { BarcodeScanner, BarcodeScannerOptions } from '@ionic-native/barcode-scanner';
将其添加到提供者数组中

providers: [
    .....
    ;;;;; Other providers
    ;;;;;
    BarcodeScanner,

  ],
和在组件中

import { BarcodeScanner, BarcodeScannerOptions } from '@ionic-native/barcode-scanner';
在构造函数中初始化

constructor(public barcodeCtrl: BarcodeScanner)
提供扫描选项

const options: BarcodeScannerOptions = {
      preferFrontCamera: false,
      showFlipCameraButton: false,
      showTorchButton: true,
      torchOn: false,
      prompt: 'Place a barcode inside the scan area',
      resultDisplayDuration: 500,
      formats: 'QR_CODE,DATA_MATRIX,UPC_A,UPC_E,EAN_8,EAN_13,CODE_39,CODE_93,CODE_128,ITF,PDF_417,AZTEC',
      orientation: 'portrait',
      disableAnimations: true, // iOS
      disableSuccessBeep: false, // iOS and Android
    };
在按钮上单击函数下面的调用

Scan(){

 this.barcodeCtrl.scan(options).then((barcodeData) => {
        console.log('Barcode data', barcodeData);
        this.licenceData = JSON.parse(barcodeData.text);  // This will contain your licence details 


        
      }).catch((err) => {
        console.log('Error', err);
      });

}