USBInterface - 提供了有关 USB 设备提供的接口的信息
USBInterface 是 WebUSB API 的接口,提供了有关 USB 设备提供的接口的信息。接口代表实现特定协议的设备功能,并且可以包含用于双向通信的端点。
构造函数
USBInterface.USBInterface
创建一个新的 USBInterface 对象,该对象将使用具有给定接口编号的 USBConfiguration 上的接口信息进行填充。
属性
USBInterface.interfaceNumber 只读
返回此接口的接口号。这等于定义该接口的接口描述符的 bInterfaceNumber 字段。
USBInterface.alternate 只读
返回此接口当前选择的替代配置。默认情况下,它是 USBAlternateInterface 的 alternates,同时其 alternateSetting 等于 0。可以通过调用 USBDevice.selectAlternateInterface() 以及在 alternates 中找到的任何其他值来更改它。
USBInterface.alternates 只读
返回一个包含 USBAlternateInterface 接口实例的数组,其中,这些实例描述了该接口可能的每种替代配置。
USBInterface.claimed 只读
通过调用 USBDevice.claimInterface() 返回当前页面是否声明了该接口。
规范
| 规范 | 状态 | 备注 |
|---|---|---|
| WebUSB USBInterface 的定义 |
草稿 | 初始定义。 |
桌面浏览器兼容性
| 特性 | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| 基础支持 | 61 | 79 | 不支持 | 不支持 | 48 | 不支持 |
USBInterface() 构造函数 | 61 | 79 | 不支持 | 不支持 | 48 | 不支持 |
alternate | 61 | 79 | 不支持 | 不支持 | 48 | 不支持 |
alternates | 61 | 79 | 不支持 | 不支持 | 48 | 不支持 |
claimed | 61 | 79 | 不支持 | 不支持 | 48 | 不支持 |
interfaceNumber | 61 | 79 | 不支持 | 不支持 | 48 | 不支持 |
移动浏览器兼容性
| 特性 | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
|---|---|---|---|---|---|---|---|
| 基础支持 | 不支持 | 61 | 未知 | 不支持 | 未知 | 45 | 不支持 |
USBInterface() 构造函数 | 不支持 | 61 | 未知 | 不支持 | 未知 | 45 | 不支持 |
alternate | 不支持 | 61 | 未知 | 不支持 | 未知 | 45 | 不支持 |
alternates | 不支持 | 61 | 未知 | 不支持 | 未知 | 45 | 不支持 |
claimed | 不支持 | 61 | 未知 | 不支持 | 未知 | 45 | 不支持 |
interfaceNumber | 不支持 | 61 | 未知 | 不支持 | 未知 | 45 | 不支持 |