Gyroscope:x 属性

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

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

Gyroscope 接口的 x 只读属性返回一个数字表示设备沿着 X 轴的角速度。

一个 Number

示例

陀螺仪通常在 reading 事件回调中读取。在下面的例子中,这种情况每秒发生 60 次。

js
let gyroscope = new Gyroscope({ frequency: 60 });

gyroscope.addEventListener("reading", (e) => {
  console.log(`沿着 X 轴的角速度 ${gyroscope.x}`);
  console.log(`沿着 Y 轴的角速度 ${gyroscope.y}`);
  console.log(`沿着 Z 轴的角速度 ${gyroscope.z}`);
});
gyroscope.start();

规范

Specification
Gyroscope
# gyroscope-x

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
x

Legend

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

Full support
Full support
No support
No support