Navigator:getVRDisplays() 方法

已弃用: 不再推荐使用该特性。虽然一些浏览器仍然支持它,但也许已从相关的 web 标准中移除,也许正准备移除或出于兼容性而保留。请尽量不要使用该特性,并更新现有的代码;参见本页面底部的兼容性表格以指导你作出决定。请注意,该特性随时可能无法正常工作。

非标准: 该特性是非标准的,请尽量不要在生产环境中使用它!

Navigator 接口的 getVRDisplays() 方法会返回兑现为 VRDisplay 对象数组的 promise,该数组代表连接到计算机的任何可用的 VR 显示器。

语法

js
getVRDisplays()

参数

无。

返回值

兑现为 VRDisplay 对象数组的 promise。

示例

有关示例代码,请参见 VRDisplay

规范

此方法属于旧版的 WebVR API(已被 WebXR 设备 API 取代)。其不再处于标准化轨道。

由于并非所有浏览器都已实现新的 WebXR API,因此建议依赖框架(例如 A-FrameBabylon.jsThree.js)或 polyfill 来开发可在所有浏览器中运行的 WebXR 应用程序 [1]

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
getVRDisplays
DeprecatedNon-standard

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
See implementation notes.
User must explicitly enable this feature.
Has more compatibility info.

参见