let that =this;
uni.createBLEConnection({
//要连接的设备id
deviceId: deviceId,
success: function(res) {
console.log("链接成功", res)
setTimeout( function() {
that.notifyBLECharacteristicValueChange()
}, 2000)
},
fail(err) {
console.log("当前蓝牙报错", err)
}
})

- 发布:2023-08-01 10:21
- 更新:2023-08-01 10:41
- 阅读:149
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 10
HBuilderX类型: 正式
HBuilderX版本号: 3.8.7
手机系统: Android
手机系统版本号: Android 13
手机厂商: OPPO
手机机型: oppo reno10 pro
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
let that =this;
uni.createBLEConnection({
//要连接的设备id
deviceId: deviceId,
success: function(res) {
console.log("链接成功", res)
setTimeout( function() {
that.notifyBLECharacteristicValueChange()
}, 2000)
},
fail(err) {
console.log("当前蓝牙报错", err)
}
})
let that =this;
uni.createBLEConnection({
//要连接的设备id
deviceId: deviceId,
success: function(res) {
console.log("链接成功", res)
setTimeout( function() {
that.notifyBLECharacteristicValueChange()
}, 2000)
},
fail(err) {
console.log("当前蓝牙报错", err)
}
})
预期结果:
在回调中可以调用
在回调中可以调用
实际结果:
报错不是一个函数
报错不是一个函数
bug描述:
uni.createBLEConnection 在success 回调函数中无法调用其他方法,bind(this),局部变量赋值this 都无法调用,报错不是一个函数
f***@163.com (作者)
好的我新建一下试试
2023-08-01 10:42
f***@163.com (作者)
不行按照官方的写法还是报错不是一个函数
2023-08-01 10:45
f***@163.com (作者)
官方的我跑了一下,是可以调用的。我复制过来了,还是不行调用不到
2023-08-01 10:52
喜欢技术的前端
回复 f***@163.com: 这就得排查你的代码了
2023-08-01 10:59
f***@163.com (作者)
回复 喜欢技术的前端: 重新装了一下,跑起来了
2023-08-01 11:06
f***@163.com (作者)
回复 喜欢技术的前端: 谢大佬
2023-08-01 11:12
喜欢技术的前端
回复 f***@163.com: 客气,解决了就好(●'◡'●)
2023-08-01 11:14