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 abstract class DeviceRequestPrompt
附注
🌐 Remarks
DeviceRequestPrompt 实例是通过 Page.waitForDevicePrompt() 方法返回的。
示例
🌐 Example
const [devicePrompt] = Promise.all([
page.waitForDevicePrompt(),
page.click('#connect-bluetooth'),
]);
await devicePrompt.select(
await devicePrompt.waitForDevice(({name}) => name.includes('My Device')),
);
属性
🌐 Properties
属性 🌐 Property | 修饰符 🌐 Modifiers | 类型 🌐 Type | 描述 🌐 Description |
|---|---|---|---|
| devices |
| 当前可选设备列表。 🌐 Current list of selectable devices. |
方法
🌐 Methods
方法 🌐 Method | 修饰符 🌐 Modifiers | 描述 🌐 Description |
|---|---|---|
| cancel() | 取消提示。 🌐 Cancel the prompt. | |
| select(device) | 在提示列表中选择一个设备。 🌐 Select a device in the prompt's list. | |
| waitForDevice(filter, options) | 解析提示中与过滤器匹配的第一个设备。 🌐 Resolve to the first device in the prompt matching a filter. |