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

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bluetooth
Experimental
getAvailability
Experimental
getDevices
Experimental
requestDevice
Experimental
options.exclusionFilters parameter
Experimental
options.filter.manufacturerData parameter
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.
User must explicitly enable this feature.
Has more compatibility info.