2017-01-26 6 views
2

Windows 10 PROバージョン1511(OSビルド10586.753)でChrome 56.0.2924.76(64ビット)を実行しています。 chromeでexperimental-web-platform-featuresを有効にし、フラグ--disable-webusb-securityと管理者として実行しました。私はgetDevicesでlocalhost(httpsを使用)にUSBデバイスリストを取得しようとしますが、chrome:// device-logは私にたくさんのデバイスを表示していますが、空のリストを取得します。何が問題なの?WebUSB getDevices空のリスト

navigator.usb.getDevices().then(function(devices){ 
    console.log(devices); 
}); 
// console outputs [] 

答えて

2

これまでにrequestDevice()を使用して、選択したデバイスでアクセス権を取得する必要があります。

navigator.usb.requestDevice().then(function(device){ 
    console.log(device); 
}); 

その後、getDevices()に電話することができます。

+0

この情報はどこから派生していますか? – Tauri28

+0

Googleのドキュメント:https://developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web#get_access_to_usb_devices – Supersharp

+0

私は十分注意深く読まなかったようです同じ記事に続いてありがとう。 – Tauri28