window.addEventListener('orientationchange', orientationChangeHandler);
orientationChangeHandler(){
// Returns the orientation in degrees (in 90-degree increments) of the viewport relative to the device's natural orientation
const orientation = window.orientation;
switch(this.orientation){
case 90:
console.log('横');
break;
case -90:
console.log('横');
break;
case 0:
console.log('竖');
case 180:
console.log('竖');
}
}
监听移动设备的旋转/orientationchange
最新推荐文章于 2022-08-16 09:53:52 发布