如何在 ionic 2 中使用 Scandit 插件



我正在尝试使用Scandit sdk或插件扫描条形码。如何在ionic2的.ts文件中导入scandit插件。
我的代码是

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { BarcodeScanner } from 'ionic-native';
import { Platform } from 'ionic-angular'
declare var Scandit;
declare var picker;
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {

constructor(public navCtrl: NavController) {
}
success(session) {
alert(session.newlyRecognizedCodes[0].data);    
}
failure(error) {
alert("Failed: " + error);    
}
scan()
{
Scandit.License.setAppKey("My key");
var settings = new Scandit.ScanSettings();
settings.setSymbologyEnabled(Scandit.Barcode.Symbology.EAN13, true);
settings.setSymbologyEnabled(Scandit.Barcode.Symbology.UPC12, true);
settings.setSymbologyEnabled(Scandit.Barcode.Symbology.EAN8, true);               
settings.setSymbologyEnabled(Scandit.Barcode.Symbology.CODE39, true);
settings.codeDuplicateFilter = -1;
picker = new Scandit.BarcodePicker(settings);
picker.continuousMode = true;
picker.getOverlayView().setViewfinderDimension(0.9, 0.2, 0.6, 0.2);
picker.setMargins(new Scandit.Margins(0, 0, 0, 200), null, 0);
picker.show(success, null, failure);
picker.startScanning();
}
stop()
{
picker.cancel();
}
start() 
{
picker.startScanning();
picker.setMargins(new Scandit.Margins(0, 0, 0, 200), null, 0.5);
picker.getOverlayView().setViewfinderDimension(0.9, 0.2, 0.6, 0.2);
}
}

我根据此链接编写此代码 - http://krishjan.com/2016/10/27/multiple-barcode-scanning-in-ioniccordova-using-scandit-api/

但它不起作用。如何使用 scandit 插件扫描条形码。

谢谢你的回答。

我解决了将插件导入 .ts 文件的问题,如下所示

import { Scanditsdk } from plugins/com.mirasense.scanditsdk.plugin/plugin.xml

然后它完美地工作。

相关内容

  • 没有找到相关文章