Skip to main content
Version: 22.9.0

DeviceRequestPrompt 类

¥DeviceRequestPrompt class

设备请求提示可让你通过 WebBluetooth 等 API 响应请求设备的页面。

¥Device request prompts let you respond to the page requesting for a device through an API like WebBluetooth.

签名:

¥Signature:

export declare class DeviceRequestPrompt

备注

¥Remarks

DeviceRequestPrompt 实例通过 Page.waitForDevicePrompt() 方法返回。

¥DeviceRequestPrompt instances are returned via the Page.waitForDevicePrompt() method.

此类的构造函数被标记为内部构造函数。第三方代码不应直接调用构造函数或创建扩展 DeviceRequestPrompt 类的子类。

¥The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the DeviceRequestPrompt class.

示例

¥Example

const [deviceRequest] = Promise.all([
page.waitForDevicePrompt(),
page.click('#connect-bluetooth'),
]);
await devicePrompt.select(
await devicePrompt.waitForDevice(({name}) => name.includes('My Device'))
);

属性

¥Properties

属性

修饰符

类型

描述

devices

DeviceRequestPromptDevice[]

当前可选设备列表。

方法

¥Methods

方法

修饰符

描述

cancel()

取消提示。

select(device)

在提示列表中选择一个设备。

waitForDevice(filter, options)

解析提示中与过滤器匹配的第一个设备。