此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Navigator:activeVRDisplays 属性

Deprecated

Avoid using this feature in new projects. Development of the WebVR API halted in favor of WebXR. This feature may be a candidate for removal from web standards or browsers.

Consider using the following features instead: WebXR.

安全上下文: 此特性仅在一些支持的浏览器安全上下文(HTTPS)中可用。

非标准: 该特性尚未标准化。我们不建议在生产环境中使用非标准特性,因为它们在浏览器中的支持有限,且可能发生变化或被移除。不过,在没有标准选项的特定情况下,它们可以作为合适的替代方案。

Navigator 接口的只读属性 activeVRDisplays 返回一个包含所有当前正在呈现(VRDisplay.ispresentingtrue)的 VRDisplay 对象的数组。

备注:此属性是旧版 WebVR API 的一部分。它已被 WebXR 设备 API 取代。

VRDisplay 对象的数组。

示例

js
function showActive() {
  const displays = navigator.activeVRDisplays;
  for (const display of displays) {
    console.log(`显示屏 ${display.displayId} 已激活。`);
  }
}

规范

此属性是旧版 WebVR API 的一部分,已被 WebXR 设备 API 取代。其不再处于标准化轨道。

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

浏览器兼容性

参见