使用ionic2开发一个二维码扫描功能
2017-04-13 14:38
399 查看
界面添加一个按钮:
<button ion-button block color="secondary" class="Scan-button" (click)="scanQR()" [disabled]="loading">点我扫描</button>
ts具体代码:
运行时会告诉你缺这个缺那个,只管npm install即可
然后编译成apk的时候会提示没有接受条款,其实是找不到依赖包,根据提示使用SDK Manager装上就行,扫描效果还是很好的。
<button ion-button block color="secondary" class="Scan-button" (click)="scanQR()" [disabled]="loading">点我扫描</button>
ts具体代码:
import { Component } from '@angular/core'; import { NavController } from 'ionic-angular'; import { BarcodeScanner } from "ionic-native"; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage { public scannedText: string; constructor(public navCtrl: NavController) { } public scanQR() { BarcodeScanner.scan().then((barcodeData) => { if (barcodeData.cancelled) { console.log("User cancelled the action!"); return false; } console.log("Scanned successfully!"); console.log(barcodeData); this.scannedText=JSON.stringify(barcodeData); }, (err) => { console.log(err); }); } }
运行时会告诉你缺这个缺那个,只管npm install即可
然后编译成apk的时候会提示没有接受条款,其实是找不到依赖包,根据提示使用SDK Manager装上就行,扫描效果还是很好的。
相关文章推荐
- 使用ionic2开发一个登录功能
- 使用ionic2开发一个登录功能
- 使用ionic2开发一个登录功能
- 使用jQuery插件开发一个完整验证功能的超酷动态留言版系统
- IOS开发小功能2:二维码扫描界面的设计(横线上下移动)
- iOS开发之使用UICollectionView实现美团App的分类功能【偶现大众点评App的一个小bug】
- iOS之使用ZbarSDK实现扫描二维码以及条形码功能
- Android高级控件(三)—— 使用Google ZXing实现二维码的扫描和生成相关功能体系
- 使用Google ZXing实现二维码的扫描和生成相关功能体系
- 前段写了一个类,类似混淆器,经过测试无误,使用后不会影响原有程序功能,附源码、开发文档等。
- 学习iOS开发之使用ZBar扫描二维码中文乱码问题
- [置顶] android开发之集成zxing,二维码,以及扫描二维码的功能实现。带源代码下载
- ... 作为 input type="button/submit/reset"的一个代替者,功能更强大, 标签的语义也更明确 是实际开发中推荐使用的一个html标签.
- jQuery插件实战之fullcalendar(日历插件) - 使用fullcalendar开发一个功能完整的富客户端会议室预定系统(转)
- 【iOS开发】ZBar的使用:二维码的生成及扫描 —— 伊禾媛
- Android开发扫描和生成二维码功能
- Android Studio 开发中的一个小功能 使用TextView搜索ListView
- iOS开发:使用苹果自带框架实现二维码和条形码扫描
- 使用jQuery tag handler开发一个带有标签功能的文章发布系统