wx.openBluetoothAdapter is nota function
发布于 5 年前 作者 yang54 8124 次浏览 来自 问答

Page({

  data:{ 

       devices:[{name:’’}]

  },

  onLoad:function(options){

    // 页面初始化 options为页面跳转所带来的参数

    //this.closeBluetooth();

    // this.onBluetoothAdapterStateChange();

    // this.onBluetoothDeviceFound();

  },

  startTest:function(){

this.showMessage(“开始搜索外围蓝牙设备…”,1500);

    this.setData({

        devices:[{name:’’}]

    })

    this.openBluetooth();

  },

  showMessage:function(info,dur){

      wx.showToast({

          title:info,

          icon: ‘loading’,

          duration:dur

      })

  },

  showModal:function(content){

      wx.showModal({

        title: ‘提示’,

        content: content

      })

  },

  //初始化蓝牙适配器

  openBluetooth:function(){

     var that = this;

    console.log(“开始初始化蓝牙适配器!”,that);

    wx.openBluetoothAdapter({

        success: function (res) {

            console.log(res)

        }

    })

  },

6 回复

@5l  测试了三个手机,其中两个安卓,都是刚开机的,仍然不行。。。

按照官方文档那样写个if(wx.openBluetoothAdapter)的兼容判断呗

安卓上面微信版本是6.5.7,IOS上面是6.5.6。都是最新的了

做兼容判断,不是判断微信是否是最新版本的吗?   但是我这边安卓/苹果的手机上  微信版本都是最新的了

查看微信版本,

回到顶部