先安装插件
ionic cordova plugin add phonegap-plugin-barcodescanner
npm install --save @ionic-native/barcode-scanner
然后在app.module.ts内引入,
import {BondedDevicePage} from '../pages/bonded-device/bonded-device';
@NgModule({
providers: [
BarcodeScanner
]
})
在页面调用
import { BarcodeScanner } from '@ionic-native/barcode-scanner';
constructor(private barcodeScanner: BarcodeScanner) { }
...
getCode(){
this.barcodeScanner.scan().then((barcodeData) => {
// Success! Barcode data is here
}, (err) => {
// An error occurred
});
}
条形码打印为
二维码看内置信息喽~