HIDDevice:opened 属性
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
备注: 此特性在 Web Worker(不包括共享 Web Worker)中可用。
HIDDevice 接口的 opened 只读属性在 HIDDevice 的连接已打开且准备传输数据时,返回 true。
值
一个布尔值,如果连接是打开的,则为 true。
示例
以下示例使用 HID.getDevices() 获取设备并将 opened 的值记录到控制台。
js
document.addEventListener("DOMContentLoaded", async () => {
let devices = await navigator.hid.getDevices();
devices.forEach((device) => {
console.log(`HID:${device.opened}`);
});
});
规范
| Specification |
|---|
| WebHID API> # dom-hiddevice-opened> |
浏览器兼容性
Loading…