【发布时间】:2018-04-30 14:17:22
【问题描述】:
我正在尝试通过蓝牙将移动请求数据发送到网络浏览器(笔记本电脑),所以我的第一步是将系统蓝牙连接到网络浏览器,但使用以下代码收到错误消息。或者有没有其他方法可以通过蓝牙将手机连接到网络浏览器以传输数据?
navigator.bluetooth.requestDevice().then(
function (d){console.log("found Device !!");},
function (e){console.log("Oh no !!",e);});
我在 chrome 中尝试了上面的代码。
错误信息:
TypeError: Failed to execute 'requestDevice' on 'Bluetooth': 1 argument required, but only 0 present
【问题讨论】:
-
如果您告诉我们错误信息,我们可以做的不仅仅是猜测。
-
@Connum - 是的,我更新了。
-
您需要为
requestDevice方法的参数提供一个options对象。 developer.mozilla.org/en-US/docs/Web/API/Bluetooth/… 和 googlechrome.github.io/samples/web-bluetooth/device-info.html 上的文档应该让您朝着正确的方向开始
标签: javascript bluetooth web-bluetooth