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

View in English Always switch to English

DeviceMotionEvent.acceleration

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2023年9月.

acceleration 属性会返回设备的加速度记录(单位:m / s2)。

备注:如果硬件无法从 acceleration 数据中移除重力加速度,则该值在DeviceMotionEvent中可能并不存在,你应当使用DeviceMotionEvent.accelerationIncludingGravity代替

acceleration是一个包括三轴(x、y、z)加速度信息的对象,每个轴都有自己的属性:

x

表示 x 轴(西到东)上的加速度

y

表示 y 轴(南到北)上的加速度

z

表示 z 轴(下到上)上的加速度

说明

Specification
Device Orientation and Motion
# dom-devicemotionevent-acceleration

浏览器兼容性

推荐浏览