--- title: DeviceMotionEvent.acceleration slug: Web/API/DeviceMotionEvent/acceleration tags: - API - Firefox OS - 传感器 - 运动传感器 - 需要示例 translation_of: Web/API/DeviceMotionEvent/acceleration ---
{{ ApiRef("Device Orientation Events") }}
acceleration属性会返回设备的加速度记录(单位:m / s2)。
var acceleration = instanceOfDeviceMotionEvent.acceleration;
acceleration
是一个包括三轴(x、y、z)加速度信息的对象,每个轴都有自己的属性:
x
y
z
Specification | Status | Comment |
---|---|---|
{{SpecName('Device Orientation')}} | {{Spec2('Device Orientation')}} | Initial specification. |
{{CompatibilityTable}}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("6")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile("6")}} | {{CompatNo}} | {{CompatNo}} | 4.2 |