此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Bluetooth

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

Web 蓝牙 APIBluetooth 接口提供了查询蓝牙可用性和请求访问这些设备的方法。

EventTarget Bluetooth

实例属性

从其父接口 EventTarget 继承属性。

实例方法

Bluetooth.getAvailability() 实验性

返回一个 Promise,其会兑现一个指示用户代理是否支持蓝牙的布尔值。一些用户代理允许用户配置一个指定该方法返回值的选项。

Bluetooth.getDevices() 实验性

返回一个 Promise,其会兑现一个包含当前来源允许访问的 BluetoothDevice 的数组。权限是通过先前调用 Bluetooth.requestDevice() 获得的。

Bluetooth.requestDevice() 实验性

返回一个 Promise,其会兑现匹配指定选项的 BluetoothDevice 对象。

规范

Specification
Web Bluetooth
# bluetooth

浏览器兼容性