问题描述
我正在使用 quagga 插件表单条码扫描仪。
当我有结果时,我想在 searchbybarcode (barcode){}
中调用 Quagga.onDetected
函数。
Quagga.onDetected((res) => {
console.log('barcode',res.codeResult.code)
this.searchbybarcode(res.codeResult.code)
});
错误 core.js:6014 错误类型错误:无法读取属性 未定义的'searchbybarcode'
searchbybarcode(barcode) {
console.log('mybarcode',barcode)
this.dataservice.GetByBarCode(barcode).then(models => {
this.PersonDetailsByBarcode = models;
})
}
更新
scanbarcode() {
if (!navigator.mediaDevices || !(typeof navigator.mediaDevices.getUserMedia === 'function')) {
this.errorMessage = 'getUserMedia is not supported';
return;
}
Quagga.init({
inputStream: {
name: "Live",type: "LiveStream",constraints: {
width: 480,height: 320,facingMode: "environment"
},},decoder: {
readers: [
"code_128_reader","ean_reader","ean_8_reader","code_39_reader","code_39_vin_reader","codabar_reader","upc_reader","upc_e_reader","i2of5_reader"
],}
},function (err) {
if (err) {
console.log(err);
return
}
console.log("Initialization finished. Ready to start");
Quagga.start();
Quagga.onProcessed(function (result) {
var drawingCtx = Quagga.canvas.ctx.overlay,drawingCanvas = Quagga.canvas.dom.overlay;
if (result) {
if (result.Boxes) {
drawingCtx.clearRect(0,parseInt(drawingCanvas.getAttribute("width")),parseInt(drawingCanvas.getAttribute("height")));
result.Boxes.filter(function (Box) {
return Box !== result.Box;
}).forEach(function (Box) {
Quagga.ImageDebug.drawPath(Box,{ x: 0,y: 1 },drawingCtx,{ color: "green",linewidth: 2 });
});
}
if (result.Box) {
Quagga.ImageDebug.drawPath(result.Box,{ color: "#00F",linewidth: 2 });
}
if (result.codeResult && result.codeResult.code) {
Quagga.ImageDebug.drawPath(result.line,{ x: 'x',y: 'y' },{ color: 'red',linewidth: 3 });
Quagga.onDetected((res) => {
console.log('barcode',res.codeResult.code)
});
}
}
});
});
}
请告诉我如何在 Quagga.onDetected
中调用函数
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)