j***@163.com
j***@163.com
  • 发布:2024-10-21 11:39
  • 更新:2024-10-21 11:39
  • 阅读:151

【报Bug】ios 无法使用扫一扫

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 15

HBuilderX类型: 正式

HBuilderX版本号: 4.29

手机系统: iOS

手机系统版本号: iOS 15

手机厂商: 苹果

手机机型: 13pm

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

<template>
<view class="content">
<button type="primary" style="width: 100%; margin-top: 100px;" @click="scanCode">扫一扫</button>
<view v-if="scannedResult">
<text>扫描结果:{{ scannedResult }}</text>
</view>
</view>
</template>

<script>
export default {
data() {
return {
scannedResult: '', // 保存扫描结果
};
},
methods: {
// 开始扫码
scanCode() {
uni.scanCode({
success: (res) => {
console.log('扫码成功:', res);
this.scannedResult = res.result; // 保存扫码结果
this.handleScanResult(res.result); // 处理扫码结果
},
fail: (err) => {
console.log('扫码失败:', err);
uni.showToast({
title: '扫码失败,请重试',
icon: 'none',
});
}
});
},

// 处理扫码结果  
handleScanResult(result) {  
  uni.showModal({  
    title: '扫描结果',  
    content: result,  
    showCancel: false,  
  });  
}  

}
};
</script>

<style scoped>
.content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}
button {
padding: 10px;
background-color: #007aff;
color: white;
border-radius: 5px;
font-size: 16px;
}
text {
margin-top: 20px;
font-size: 18px;
}
</style>

操作步骤:

uni.scanCode

预期结果:

可以扫码

实际结果:

无法扫码。 黑屏。 打开相册 二维码。 提示 barcode 未启用

bug描述:

11:34:17.684 [JS Framework] Failed to execute the callback function:
11:34:17.684 TypeError: this.$refs.barcode.cancel is not a function. (In 'this.$refs.barcode.cancel()', 'this.$refs.barcode.cancel' is undefined) __ERROR

已经打包了 barcode 但是手机 基座调试 一直提示我没有

2024-10-21 11:39 负责人:无 分享
已邀请:

要回复问题请先登录注册