(条码扫描)Barcode Scanner

Barcode Scanner

条码扫描器插件打开相机视图,并自动扫描条形码,将数据返回给您。
需要Cordova插件:phonegap-plugin-barcodescanner
。 有关更多信息,请参阅 BarcodeScanner plugin docs.
Repo(备用): https://github.com/phonegap/phonegap-plugin-barcodescanner

Installation(安装)

1.安装Cordova和Ionic原生插件:

$ ionic cordova plugin add phonegap-plugin-barcodescanner
$ npm install --save @ionic-native/barcode-scanner

2.添加插件到app's module

Supported platforms(支持平台)

Android
BlackBerry 10
Browser
iOS
Windows

Usage(用法)

import { BarcodeScanner } from '@ionic-native/barcode-scanner';

constructor(private barcodeScanner: BarcodeScanner) { }

...


this.barcodeScanner.scan().then((barcodeData) => {
 // Success! Barcode data is here
}, (err) => {
    // An error occurred
});

Instance Members(实例成员)

Encode

scan(options)

打开条码扫描器。

参数 类型 详情
options BarcodeScannerOptions 选择传递给扫描仪的选项

****Returns:** Promise<any>
返回使用扫描仪数据解析的Promise,或拒绝错误。

encode(type, data)

将数据编码成条形码。 注意:在Android上没有得到很好的支持

参数 类型 详情
type string 编码类型
data any 要编码的数据

****Returns:** Promise<any>

BarcodeScannerOptions

参数 类型 详情
preferFrontCamera boolean 喜欢前置摄像头 支持iOS和Android (可选)
showFlipCameraButton boolean 显示翻转相机按钮。 支持iOS和Android (可选)
showTorchButton boolean 显示手电按钮。 支持iOS和Android (可选)
disableAnimations boolean 禁用动画。 仅在iOS上支持(可选)
disableSuccessBeep boolean 禁用成功蜂鸣声。 仅在iOS上支持(可选)
prompt string 提示文字 仅在Android上支持(可选)
formats string 格式以逗号分隔。 默认为除PDF_417和RSS_EXPANDED之外的所有格式(可选)
orientation string 方向。 仅在Android上支援 可以设置为纵向或横向。 默认为无,用户可以旋转手机并选择方向。(可选)
torchOn boolean 手电筒开启(如果可用)启动。 仅在Android上支持(可选)
resultDisplayDuration number 显示X ms的扫描文本。 0完全禁用它,默认为1500.仅在Android上支持(可选)

BarcodeScanResult

参数 类型
format 'QR_CODE' 丨 'DATA_MATRIX' 丨'UPC_E' 丨 'UPC_A' 丨 'EAN_8' 丨 'EAN_13' 丨 'CODE_128' 丨 'CODE_39' 丨 'CODE_93' 丨 'CODABAR' 丨 'ITF' 丨 'RSS14' 丨 'RSS_EXPANDED' 丨 'PDF417' 丨 'AZTEC' 丨 'MSI'
cancelled boolean
text string
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容