Mac iOS-----PhoneGap 添加條形掃描碼外掛程式

來源:互聯網
上載者:User

標籤:

此隨筆記錄的是通過plugman來安裝phonegap外掛程式。

 

第1步:安裝plugman

npm install -g plugman

QiaodeMacBook-Pro:MyApp root# npm install -g plugmannpm WARN engine [email protected]1.3.4: wanted: {"node":">=0.6","npm":"1"} (current: {"node":"0.12.2","npm":"2.7.4"})npm WARN installMany normalize-package-data was bundled with [email protected]1.3.4, but bundled package wasn‘t found in unpacked treenpm WARN engine [email protected]3.9.0: wanted: {"node":"~0.10.x"} (current: {"node":"0.12.2","npm":"2.7.4"})npm WARN engine [email protected]2.2.1: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"0.12.2","npm":"2.7.4"})/usr/local/node/bin/plugman -> /usr/local/node/lib/node_modules/plugman/main.js[email protected]0.23.1 /usr/local/node/lib/node_modules/plugman├── [email protected]1.7.0├── [email protected]1.0.1├── [email protected]1.0.9 ([email protected]1.0.5)├── [email protected]0.5.2 ([email protected]0.1.3, [email protected]0.2.11, [email protected]1.1.0, [email protected]0.0.10)├── [email protected]1.3.4 ([email protected]2.0.0)└── cordova[email protected]5.0.0 ([email protected]0.0.1, [email protected]0.1.0, [email protected]0.2.3, [email protected]0.0.6, [email protected]1.2.11, [email protected]1.3.3, [email protected]2.1.0, [email protected]0.3.0, [email protected]1.1.0, [email protected]0.6.7, [email protected]0.1.16, [email protected]0.6.3, [email protected]0.1.5, [email protected]4.0.6, [email protected]3.9.0, [email protected]1.0.2, [email protected]1.1.0, [email protected]1.1.0, [email protected]1.4.2, [email protected]0.4.4, [email protected]2.47.0, [email protected]3.9.0)

 

第2步:進入項目根目錄下載外掛程式

QiaodeMacBook-Pro:Desktop root# cd MyAppQiaodeMacBook-Pro:MyApp root# git clone https://github.com/wildabeast/BarcodeScanner.git plugins/com.phonegap.plugins.barcodescannerCloning into ‘plugins/com.phonegap.plugins.barcodescanner‘...remote: Counting objects: 1735, done.remote: Total 1735 (delta 0), reused 0 (delta 0), pack-reused 1735Receiving objects: 100% (1735/1735), 3.87 MiB | 572.00 KiB/s, done.Resolving deltas: 100% (515/515), done.Checking connectivity... done.

 

第3步:開始安裝

QiaodeMacBook-Pro:MyApp root# plugman install --plugins_dir plugins --plugin com.phonegap.plugins.barcodescanner --platform ios --project platforms/iosInstalling "com.phonegap.plugins.barcodescanner" for ios

 

第4步:測試

開啟index.html,添加一個連結,並增加1個點擊事件。代碼如下:

<a class="button addBtn" id="BarcodeScanner">BarcodeScanner</a><script>$("#BarcodeScanner").click(function(){     cordova.plugins.barcodeScanner.scan(             function(result) {                 alert("Scanned Code: " + result.text + ". Format: " + result.format                     + ". Cancelled: " + result.cancelled);               }, function(error) {                   alert("Scan failed: " + error);               }); })</script>    

 

PS:記的不要少了引入phonegap的js,否則調用不了

<script src="cordova.js"></script>

 

Mac iOS-----PhoneGap 添加條形掃描碼外掛程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.