这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

displayId 只读特性在 Gamepad interface 返回 VRDisplay.displayId of the associated VRDisplay — the VRDisplay that the gamepad is controlling the displayed scene of.

A Gamepad is considered to be associated with a VRDisplay if it reports a pose that is in the same space as the VRDisplay.pose .

句法

var myDisplayId = gamepadInstance.displayId;
					

A number representing the associated VRDisplay.displayId . If the number is 0, then the gamepad is not associated with a VR display.

范例

window.addEventListener("gamepadconnected", function(e) {
  if(!e.gamepad.displayId) {
    console.log('Gamepad connected');
  } else {
    console.log('Gamepad connected, associated with VR display ' + e.gamepad.displayId);
  }
});
					

规范

规范 状态 注释
WebVR 1.1
The definition of 'displayId' in that specification.
草案 初始定义

浏览器兼容性

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
displayId 弃用 Chrome ? — 80 Disabled
不支持 ? — 80 Disabled
Only works on desktop in an experimental version of Chrome (other builds won't return any devices when Navigator.getVRDisplays() is invoked).
Disabled Until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Edge 15 Firefox 55
55
Windows support was enabled in Firefox 55.
64
macOS support was enabled in Firefox 64.
IE No Opera ? Safari No WebView Android No Chrome Android ? — 80
不支持 ? — 80
Currently supported only by Google Daydream.
Firefox Android 55 Opera Android ? Safari iOS No Samsung Internet Android Yes
Yes
Currently supported only by Google Daydream.

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

另请参阅

元数据

  • 最后修改: