在Windows 10 PRO版本1511 (操作系统内部版本10586.753)上运行Chrome 56.0.2924.76 (64位)。我在chrome上启用了实验性的-web-platform-功能,并以管理员身份使用--disable-webusb-security运行它。我尝试用getDevices获取本地主机上的USB设备列表(使用https),但得到的列表是空的,尽管chrome:// device -log显示了大量的设备。可能的问题是什么?
navigator.usb.getDevices().then(function(devices){
console.log(devices);
});
// console outputs []发布于 2017-02-03 09:04:03
您应该使用之前的requestDevice()来获取对所选设备的访问权限。
navigator.usb.requestDevice({filters:[]}).then(function(device){
console.log(device);
});在此之后,您将能够调用getDevices()。
https://stackoverflow.com/questions/41876880
复制相似问题