uni.scanCode({
scanType: ['barCode'],
success: function (res) {
console.log(res);
uni.hideLoading();
that.brcodeCheck(res.scanType,res.result);
},
fail:function(){
uni.hideLoading();
}
});
- 发布:2024-01-03 15:48
- 更新:2024-01-03 17:46
- 阅读:208
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10 专业版
HBuilderX类型: 正式
HBuilderX版本号: 3.99
第三方开发者工具版本号: 1.06.2301160
基础库版本号: 3.22
项目创建方式: HBuilderX
示例代码:
操作步骤:
uni.scanCode({
scanType: ['barCode'],
success: function (res) {
console.log(res);
uni.hideLoading();
that.brcodeCheck(res.scanType,res.result);
},
fail:function(){
uni.hideLoading();
}
});
uni.scanCode({
scanType: ['barCode'],
success: function (res) {
console.log(res);
uni.hideLoading();
that.brcodeCheck(res.scanType,res.result);
},
fail:function(){
uni.hideLoading();
}
});
预期结果:
能扫到
能扫到
实际结果:
console.log(res);有值。
console.log(res);有值。
喜欢技术的前端 - QQ---445849201
写了个demo .真机调试可以的
<template>
<view class="page-body">
<button @click="barCode">barCode</button>
</view>
</template>
<script>
export default {
data() {
return {
};
},
onLoad() {
},
methods: {
barCode() {
uni.scanCode({
scanType: ['barCode'],
success: function(res) {
console.log(res);
},
fail: function(err) {
console.log(err)
}
});
}
}
};
</script>
<style>
</style>
1***@qq.com (作者)
好像是我手机的问题,昨天不能,今天突然又能调用了,应该是没电重启后好用了,抱歉。
2024-01-04 11:12