ionic添加cordova插件-BarcodeScanner

来源:互联网 发布:关于网络管理的书 编辑:程序博客网 时间:2024/06/05 05:23

BarcodeScanner
打开相机自动扫描 条形码/二维码,返回数据。

cordova plugin add phonegap-plugin-barcodescanner

方法(Methods)

scan()
返回 对象 - 信息

encode(type, text)
参数 类型 说明
type Constant 编码类型(如:barcodescanner。编码。text_type)
text String 编码所需的文本字符串

返回 - 对象/编码文本

Example

module.controller('BarcodeCtrl', function($scope, $cordovaBarcodeScanner) {  document.addEventListener("deviceready", function () {    $cordovaBarcodeScanner      .scan()      .then(function(barcodeData) {        // Success! Barcode data is here 扫描数据:barcodeData.text      }, function(error) {        // An error occurred      });    // NOTE: encoding not functioning yet    $cordovaBarcodeScanner      .encode(BarcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com")      .then(function(success) {        // Success!      }, function(error) {        // An error occurred      });  }, false);});
0 0
原创粉丝点击