Skip to content

Usb设备模块

点我查看API

集成和使用ESUsbDeviceModule模块。

  • ESUsbDeviceManager是对ESUsbDeviceModule进一步封装。
  • 开发者可以直接使用ESUsbDeviceModule。建议直接使用ESUsbDeviceManager

集成

package.json引入库

点击查看源码
js
"@extscreen/es-core": "^x.x.x"

获取Usb设备列表

示例代码

点击查看源码
js
 ESUsbDeviceManager.getUsbDeviceList().then(
    (usbDeviceList) => {
    },
    error => {
    }
);

获取Usb设备信息

示例代码

点击查看源码
js
let vendorId = 30021;
let productId = 10244;
ESUsbDeviceManager.getUsbDevice(vendorId, productId).then(
    (usbDevice) => {
    },
    error => {
    }
);

批量获取Usb设备信息

示例代码

点击查看源码
js
ESUsbDeviceManager.getUsbDeviceListByArray(
    [[30021, 10244], [3034, 51232]]
).then(
    (usbDeviceList) => {
    },
    error => {
    }
);

Usb设备是否获取权限

示例代码

点击查看源码
js
ESUsbDeviceManager.isUsbDevicePermissionsGranted(30021, 10244).then(
    (hasPermissionsGranted) => {
    },
    error => {
    }
);

请求Usb设备权限

示例代码

点击查看源码
js
ESUsbDeviceManager.requestUsbDevicePermission(30021, 10244).then(
    (requestUsbDevicePermission) => {
    },
    error => {
    }
);

监听Usb设备插拔

示例代码

点击查看源码
js
//1.页面mixin ESUsbDevice
export default {
    mixins: [ESUsbDevice],
    data() {
        return {}
    },
    methods: {
        //2.覆写监听方法
        //usb设备插入
        onESUsbDeviceAttached(usbDevice) {
        },
        //usb设备拔出
        onESUsbDeviceDetached(usbDevice) {
        },
    }
}