uniapp有调用扫码功能uni.scanCode的api。但是该功能扫码在安卓上准确率低。
推荐使用 Barcode模块管理条码
https://www.html5plus.org/doc/zh_cn/barcode.html
this.barcode = plus.barcode.create('barcode', [plus.barcode.QR, plus.barcode.CODE128], {
top: 'auto',
left: 'auto',
width: '100%',
height: '50%',
position: 'absolute'
});
const onMarked = (type, result) => {
console.log(type, result);
this.barcode.close()
}
this.barcode.onmarked = onMarked
this.currentWebview = this.$scope.$getAppWebview();
this.currentWebview.append(this.barcode)
this.barcode.start();
这样就可以形成一个正方形的扫码控件,并且固定在顶部
可以打印出来 console.log(type, result);