From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- files/ru/web/api/usb/getdevices/index.html | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 files/ru/web/api/usb/getdevices/index.html (limited to 'files/ru/web/api/usb/getdevices') diff --git a/files/ru/web/api/usb/getdevices/index.html b/files/ru/web/api/usb/getdevices/index.html new file mode 100644 index 0000000000..8b69fce817 --- /dev/null +++ b/files/ru/web/api/usb/getdevices/index.html @@ -0,0 +1,63 @@ +--- +title: USB.getDevices() +slug: Web/API/USB/getDevices +tags: + - API + - Method + - Reference + - USB + - WebUSB + - WebUSB API + - getDevices() +translation_of: Web/API/USB/getDevices +--- +

{{APIRef("WebUSB API")}}{{SeeCompatTable}}{{securecontext_header}}

+ +

Метод getDevices интерфейса {{DOMxRef("USB")}} возвращает {{JSxRef("Promise")}}, который разрешается с массивом {{DOMxRef("USBDevice")}} объектов сопряжённых подключённых устройств. Для информации о сопряжённых устройствах, смотрите {{DOMxRef("USB.requestDevice()")}}.

+ +

Синтаксис

+ +
USB.getDevices()
+ +

Параметры

+ +

Нет.

+ +

Возвращаемое значение

+ +

{{JSxRef("Promise")}}, который разрешается с массивом объектов {{DOMxRef("USBDevice")}}.

+ +

Пример

+ +

В следующем примере имена продуктов и серийные номера сопряжённых устройств выводятся в консоль. Для информации о сопряжённых устройствах, смотрите {{DOMxRef("USB.requestDevice","USB.requestDevice()")}}.

+ +
navigator.usb.getDevices()
+.then(devices => {
+  console.log("Total devices: " + devices.length);
+  devices.forEach(device => {
+    console.log("Product name: " + device.productName + ", serial number " + device.serialNumber);
+  });
+});
+ +

Спецификация

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("Web USB","#dom-usb-getdevices","getDevices")}}{{Spec2("Web USB")}}Изначальное определение.
+ +

Совместимость с браузерами

+ + + +

{{Compat("api.USB.getDevices")}}

-- cgit v1.2.3-54-g00ecf