Vue.js 在nativescript vue中使用类似条形码扫描仪的插件
我正在尝试将条形码扫描仪插件与nativescript vue一起使用,因此首先我使用npm安装它,就像在我的项目中一样: npm安装nativescript条形码扫描仪 然后我在src/main.js文件中注册它: 注册表项('BarcodeScanner',()=>require('nativescript-BarcodeScanner')。BarcodeScanner) 然后我尝试了很多方法将扫描仪包括在我的vue组件中,但总是出现错误。有人知道如何在nativescript vue中使用此组件吗 作为xml组件,它返回一个帧错误:Vue.js 在nativescript vue中使用类似条形码扫描仪的插件,vue.js,nativescript,barcode-scanner,nativescript-vue,Vue.js,Nativescript,Barcode Scanner,Nativescript Vue,我正在尝试将条形码扫描仪插件与nativescript vue一起使用,因此首先我使用npm安装它,就像在我的项目中一样: npm安装nativescript条形码扫描仪 然后我在src/main.js文件中注册它: 注册表项('BarcodeScanner',()=>require('nativescript-BarcodeScanner')。BarcodeScanner) 然后我尝试了很多方法将扫描仪包括在我的vue组件中,但总是出现错误。有人知道如何在nativescript vue中使用
<BarcodeScanner
class="scanner-round"
formats="QR_CODE, EAN_13"
beepOnScan="true"
reportDuplicates="true"
preferFrontCamera="false"
(scanResult)="onScanResult($event)">
</BarcodeScanner>
事实上,我们需要使用普通的javascript才能像这样使用这个barcodescanner插件:
const BarcodeScanner = require("nativescript-barcodescanner").BarcodeScanner;
然后在计算方法中:
var barcodescanner = new BarcodeScanner();
然后使用这个类:
barcodescanner
.scan(
{
// Enter here your scanner preferences
}
)
.then(
result => {
// handle here the barcode result.
}
)
我很好奇,我正在尝试在nativescript vue上实现条形码扫描仪,我得到了相同的帧错误,我不认为您的答案是明确的。。。我做了
npm安装-s nativescript barcodescanner
然后我按照你的回答做了,我不理解没有函数的计算方法,它只是一个变量。你是最好的!!:)感谢您的解决方案!!:)