日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

window.navigator.hid Cannot read properties of undefined

作者:魯尼的小寶貝 更新時間: 2022-03-15 編程語言
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getDevices')
    at SoftKey3A.FindPort (SoftKey3A.js:278)
    at n.<anonymous> (index.js:105)
    at s (runtime.js:63)
    at Generator._invoke (runtime.js:293)
    at Generator.next (runtime.js:118)
    at a (asyncToGenerator.js:3)
    at s (asyncToGenerator.js:25)
    at asyncToGenerator.js:32
    at new Promise (<anonymous>)
    at n.<anonymous> (asyncToGenerator.js:21)

使用 navigator 讀取識別 ukey,報出這個問題,在本地是可以的,但是在測試環境上就出問題了,報

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getDevices')

查詢了好多地方,各種修改都報錯。

突然詳情,瀏覽器的api是否和ssl有關系,正式環境使用的是 https,使用沒有問題,但是在測試環境使用的http,使用https訪問就不會有這個問題了。

在這兒可以印證需要這個操作

https://developer.mozilla.org/en-US/docs/Web/API/HID

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

?

所以,非本地訪問,得使用https訪問。

原文鏈接:https://blog.csdn.net/poem_2010/article/details/122819624

欄目分類
最近更新