window.addEventListener("orientationchange", function () {
console.log(screen.orientation.type + " " +
screen.orientation.angle
);
});
screen.orientation.addEventListener(
"change",
function (e) {
console.log(screen.orientation.type + " " + screen.orientation.angle);
},
false
);
screen.orientation.type
portrait-primary
:竖屏状态并且旋转角度为 0 度,也就是设备的自然位置landscape-primary
:横屏状态并且旋转角度为 90 度portrait-secondary
:竖屏状并且即旋转角度为 180 度,也就是倒着拿的位置landscape-secondary
:横屏状态并且旋转角度为 270 度