blob: 6bc95b71f2a3197eee6fccbe1853f7ca6a27dfb8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
---
title: USB
slug: Web/API/USB
translation_of: Web/API/USB
---
<p>{{SeeCompatTable}}{{APIRef("WebUSB API")}}</p>
<p><a href="/en-US/docs/Web/API/WebUSB_API">WebUSB API</a> 接口提供了从网页查找和连接USB设备的属性和方法</p>
<h2 id="属性">属性</h2>
<p>None.</p>
<h3 id="Event_handlers">Event handlers</h3>
<dl>
<dt>{{domxref("USB.onconnect")}}</dt>
<dd>每当连接到先前配对的设备时,调用此事件处理器。</dd>
<dt>{{domxref("USB.ondisconnect")}}</dt>
<dd>每当配对设备断开连接时,调用此事件处理器。</dd>
</dl>
<h2 id="方法">方法</h2>
<dl>
<dt>{{domxref("USB.getDevices()")}}</dt>
<dd>Returns a {{jsxref("Promise")}} that resolves with an array of {{domxref("USBDevice")}} objects for paired attached devices.</dd>
<dt>{{domxref("USB.requestDevice()")}}</dt>
<dd>Returns a {{jsxref("Promise")}} that resolves with an instance of {{domxref("USBDevice")}} if the specified device is found. Calling this function triggers the user agent's pairing flow.</dd>
</dl>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('Web USB','#enumeration','USB')}}</td>
<td>{{Spec2('Web USB')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("api.USB")}}</p>
|