HIDDevice: thuộc tính productId

Khả dụng hạn chế

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

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Note: This feature is available in Web Workers, except for Shared Web Workers.

Thuộc tính chỉ đọc productId của giao diện HIDDevice trả về ID sản phẩm của thiết bị HID đang kết nối.

Giá trị

Một số nguyên. Nếu thiết bị không có ID sản phẩm hoặc không thể truy cập ID sản phẩm, giá trị này sẽ là 0.

Ví dụ

Ví dụ sau lấy danh sách thiết bị bằng HID.getDevices() và ghi giá trị productId ra console.

js
let devices = await navigator.hid.getDevices();
devices.forEach((device) => {
  console.log(`HID: ${device.productId}`);
});

Thông số kỹ thuật

Thông số kỹ thuật
WebHID API
# dom-hiddevice-productid

Tương thích trình duyệt