二维码和多选图片插件整理简单实用

来源:互联网 发布:sql语句编写工具 编辑:程序博客网 时间:2024/05/17 10:39
二维码扫描插件 适用于3.X+ ios android wp
使用扫码插件
如果是phonegap
cd D:\Code\Android\sencha\MyApp\phonegap  
phonegap plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner向工程中安装barcodescanner插件


如果是Cordova
cd D:\Code\Android\sencha\MyApp\cordova  
cordova plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner向工程中安装barcodescanner插件


js调用:
cordova.plugins.barcodeScanner.scan(
      function (result) {
          alert("We got a barcode\n" +
                "Result: " + result.text + "\n" +
                "Format: " + result.format + "\n" +
                "Cancelled: " + result.cancelled);
      }, 
      function (error) {
          alert("Scanning failed: " + error);
      }
   );






  phonegap 多图片选择插件
github地址:https://github.com/wymsee/cordova-imagePicker
在线安装地址:
phonegap plugin add https://github.com/wymsee/cordova-imagePicker.git


cordova plugin add https://github.com/wymsee/cordova-imagePicker.git
js调用:


//可选择所有图片
window.imagePicker.getPictures(
    function(results) {
        for (var i = 0; i < results.length; i++) {
            console.log('Image URI: ' + results[i]);
        }
    }, function (error) {
        console.log('Error: ' + error);
    }
);




//最多可选十张图片
window.imagePicker.getPictures(
    function(results) {
        for (var i = 0; i < results.length; i++) {
            console.log('Image URI: ' + results[i]);
        }
    }, function (error) {
        console.log('Error: ' + error);
    }, {
        maximumImagesCount: 10,
        width: 800
    }
);
1 0
原创粉丝点击