首先对DeviceMotionEvent进行优化: 去除没用的代码,又一次封装DeviceMotionEven if(window.DeviceMotionEvent) { var speed = 25;//定义一个数值 var x = y = z = lastX = lastY = lastZ = 0;//重置全部数值 window.addEventListener('devicemotion', function(){ var acceleration =event.acceleration…