华为手机调试 wx.onBluetoothDeviceFound的回调怎么不执行了?
发布于 5 年前 作者 hejing 354 次浏览 来自 问答

已经在三台华为手机上测试过了,回调都不会执行。一个月前我们迭代过项目,那个时候测试还能执行回调的。不会吧,现在心态直接爆炸了。以下极简单的代码,就可以验证结果。

测试代码:

  testHuawei: function () {

    wx.openBluetoothAdapter({

      success(res) {

        console.log("openBluetoothAdapter res: ", res);

        wx.onBluetoothDeviceFound(function (res) {

          // 这里有数据,则测试成功

          console.log("onBluetoothDeviceFound res: ", res);

        });

        wx.startBluetoothDevicesDiscovery({

          success(res) {

            console.log("startBluetoothDevicesDiscovery res: ", res);

          },

          fail(err) {

            console.error("startBluetoothDevicesDiscovery err: ", err);

          },

        });

        setTimeout(() => {

          wx.stopBluetoothDevicesDiscovery({

            success(res) {

              console.log("stopBluetoothDevicesDiscovery res: ", res);

            },

            fail(err) {

              console.error("startBluetoothDevicesDiscovery err: ", err);

            },

          });

        }, 10000);

      },

      fail(err) {

        console.error("openBluetoothAdapter err: ", err);

      },

    });

  },

2 回复

你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

麻烦在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点(具体到分钟)

真的心态爆炸了。这已经是最简单的代码了,在华为上居然都跑不了结果

回到顶部