USB

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

WebUSB API 接口提供了从网页查找和连接 USB 设备的属性和方法

属性

None.

Event handlers

USB.onconnect

每当连接到先前配对的设备时,调用此事件处理器。

USB.ondisconnect

每当配对设备断开连接时,调用此事件处理器。

方法

USB.getDevices()

Returns a Promise that resolves with an array of USBDevice objects for paired attached devices.

USB.requestDevice()

Returns a Promise that resolves with an instance of USBDevice if the specified device is found. Calling this function triggers the user agent's pairing flow.

规范

Specification
WebUSB API
# usb

Browser compatibility

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
USB
Experimental
connect event
Experimental
disconnect event
Experimental
getDevices
Experimental
requestDevice
Experimental
Available in workers
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.
Has more compatibility info.