uniapp 使用camera组件 自定义扫一扫界面 一直扫描不出二维码来, onScanCode一直没有被调用
<template>
<view class="scan-view">
<!-- <camera class='scan-camera' mode="scanCode" binderror="cameraError" bindscancode='scancode' frame-size='large'> -->
<camera class='scan-camera' mode="scanCode" @error="onCameraError" @scancode="onScanCode" @ready="onCameraInit"
frame-size='large' device-position="back" flash="off">
<view class="boxs">
<view class="qr-scanner">
<view class="box">
<view class="line"></view>
</view>
</view>
<view class='cover-corner cover-left-top'></view>
<view class='cover-corner cover-right-top'></view>
<view class='cover-corner cover-left-bottom'></view>
<view class='cover-corner cover-right-bottom'></view>
</view>
</camera>
</view>
</template>
<script>
export default {
data() {
return {
hasScan: false, // 是否扫描成功
}
},
methods: {
onScanCode(e) {
console.log(e)
// 若扫描成功,不进行后续处理
if (this.data.hasScan) {
return
}
},
},
}
</script>
追加: 我发现在进行真机调试的时候不回调用onScanCode, 单独在手机上运行开发版本的时候能扫码识别成功并且调用onScanCode
后台协议更新试一下
测试可以扫出来