再h5项目中使用html5qcode 实现扫码的功能,但是部署好后会提示错误
代码如下
start() {
this.html5QrCode = new Html5Qrcode('reader');
console.log("扫描二维码");
this.html5QrCode
.start(
this.cameraId, // retreived in the previous step.
{
fps: 10, // sets the framerate to 10 frame per second
qrbox: 250 // sets only 250 X 250 region of viewfinder to
// scannable, rest shaded.
},
qrCodeMessage => {
this.scantext = qrCodeMessage
// do something when code is read. For example:
if (qrCodeMessage) {
// uni.$showMsg(qrCodeMessage)
// uni.$showMsg(qrCodeMessage, 999)
// this.$refs.uToast.show({
// title: `扫码成功`,
// type: 'success'
// });
this.$emit('change', qrCodeMessage)
this.stop();
//console.log('扫码成功', qrCodeMessage);
//参数
}
},
errorMessage => {
// uni.$showMsg('errorMessage' + errorMessage)
// parse error, ideally ignore it. For example:
console.log(`QR Code no longer in front of camera.`);
}
)
.catch(err => {
// Start failed, handle it. For example,
console.log(`Unable to start scanning, error: ${err}`);
// this.$refs.uToast.show({
// title: `扫码失败:${err}`,
// type: 'error'
// });
uni.$showMsg(err)
});
},