uni.scanCode({
// barCodeInput: true,
success: function(res) {
console.log(JSON.stringify(res));
console.log('条码内容:' + res.result);
that.deviceId = that.getValue(res.result, 'SN')
that.wifiPassword = that.getValue(res.result, 'PWD')
},
fail: function(e) {
console.log(JSON.stringify(e));
uni.showToast({
title: JSON.stringify(e),
icon: 'none',
duration: 1500
})
}
});
getValue(str, key) {
let result = new RegExp(`(?:^|;)${key}:([^;]*)`).exec(str);
if (result == null) {
return "-";
} else {
return result && result[1];
}
},

- 发布:2023-04-26 17:24
- 更新:2023-04-26 19:51
- 阅读:181
产品分类: HbuilderX
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 11.7.1
HBuilderX版本号: 3.7.10
示例代码:
操作步骤:
uni.scanCode({
// barCodeInput: true,
success: function(res) {
console.log(JSON.stringify(res));
console.log('条码内容:' + res.result);
that.deviceId = that.getValue(res.result, 'SN')
that.wifiPassword = that.getValue(res.result, 'PWD')
},
fail: function(e) {
console.log(JSON.stringify(e));
uni.showToast({
title: JSON.stringify(e),
icon: 'none',
duration: 1500
})
}
});
getValue(str, key) {
let result = new RegExp(`(?:^|;)${key}:([^;]*)`).exec(str);
if (result == null) {
return "-";
} else {
return result && result[1];
}
},
uni.scanCode({
// barCodeInput: true,
success: function(res) {
console.log(JSON.stringify(res));
console.log('条码内容:' + res.result);
that.deviceId = that.getValue(res.result, 'SN')
that.wifiPassword = that.getValue(res.result, 'PWD')
},
fail: function(e) {
console.log(JSON.stringify(e));
uni.showToast({
title: JSON.stringify(e),
icon: 'none',
duration: 1500
})
}
});
getValue(str, key) {
let result = new RegExp(`(?:^|;)${key}:([^;]*)`).exec(str);
if (result == null) {
return "-";
} else {
return result && result[1];
}
},
预期结果:
扫码内容解析到输入框
扫码内容解析到输入框
实际结果:
页面卡顿,奔溃了
页面卡顿,奔溃了
bug描述:
苹果发布正式版app扫码崩溃,真机调试是没有问题的

FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866
manifest.json-> App模块配置 -> 扫码 勾选
2***@qq.com (作者)
已经勾选了,还是有问题
2023-04-27 09:05