USBDevice: thuộc tính configuration

Khả dụng hạn chế

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

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

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

Note: This feature is available in Web Workers.

Thuộc tính chỉ đọc configuration của giao diện USBDevice trả về một đối tượng USBConfiguration cho giao diện hiện đang được chọn của thiết bị USB đã ghép nối.

Giá trị

Một đối tượng USBConfiguration.

Ví dụ

Ví dụ sau đây sử dụng thuộc tính này để kiểm tra sự tồn tại của thuộc tính USBConfiguration nhằm chọn cấu hình trước khi chiếm giữ giao diện.

js
async function connectDevice(usbDevice) {
  await usbDevice.open();
  if (usbDevice.configuration === null) await usbDevice.selectConfiguration(1);
  await usbDevice.claimInterface(0);
}

Thông số kỹ thuật

Thông số kỹ thuật
WebUSB API
# dom-usbdevice-configuration

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