代码如下:
import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { BarcodeScanner } from '@ionic-native/barcode-scanner';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController, private translate: TranslateService, private barcodeScanner: BarcodeScanner) {
}
//Switch language
changelanguage() {
let browserLang = this.translate.currentLang;
this.translate.use(browserLang.match(/en/) ? 'zh' : 'en');
}
//Scan test
ScanCode() {
this.barcodeScanner.scan()
.then((result) => {
console.log(result);
})
.catch((error) => {
alert(error);
});
}
}
错误图片:
出现了新问题:
根据Suraj的建议,提示"plugin_not_installed"
错误图片:
开发环境:Visual Studio 2017