安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

getDevices() 方法为 蓝牙 interface of Web Bluetooth API exposes the Bluetooth devices this origin is allowed to access. This method does not display any permission prompts.

注意: 此方法返回 BluetoothDevice for each device the origin is currently allowed to access, even the ones that are out of range or powered off. The program can detect when a device comes online or into range by watching for BlueTooth advertisements by calling BluetoothDevice.watchAdvertisements() on that device.

句法

var readerPromise = Bluetooth.getDevices();
					

参数

None.

返回值

A Promise that resolves with an array of BluetoothDevice

异常

This method doesn't throw any exceptions.

规范

规范 状态 注释
Web Bluetooth
The definition of 'getDevices()' in that specification.
草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

No compatibility data found. Please contribute data for "api.Bluetooth.getDevices" (depth: 1) to the MDN 兼容性数据存储库 .

元数据

  • 最后修改: