使用二维码打开离子中的内部页面2
我是离子2和cordova开发的新手,我正在测试cordova插件“条形码扫描仪”以了解我能用它做什么。 我想用插件阅读包含我应用中内部页面链接的QR码,然后打开此页面。使用二维码打开离子中的内部页面2
我试过用this.navCtrl.push,但我不知道它为什么没有工作。 这里是我的代码:
click(){
this.barcodeScanner.scan().then((barcodeData) => {
this.navCtrl.push(barcodeData.text, data);
}, (err) => {
alert('Error');
});
}
在此先感谢。
先安装这个插件,
$离子插件添加的PhoneGap-插件,barcodescanner
$ NPM安装--save @离子本地/ barcodescanner
你可以从
“从@ ionic-native/barcode-scanner'导入{BarcodeScanner};”
然后以html和代码这.TS创建一个点击按钮,类似“扫描”文件
click() {
BarcodeScanner.scan()
.then((result) => {
if (!result.cancelled) {
const barcodeData = new BarcodeData(result.text, result.format);
this.scanDetails(barcodeData);
}
})
.catch((err) => {
alert(err);
})
}
Now just feed the link which you need to open in QRcode and scan it..
这将像JavaScript中的“window.open”一样工作吗?我尝试使用没有离子的插件,只使用JavaScript和它的工作,但打字稿是不同的,所以我不知道该怎么做。 –
typescript不过是JS的超集,我提到的代码可以很好地处理.ts文件 –
使用ionic3 lazyloader或使用deeplinking可以实现它。 – TriDiamond