JS - 监听手机横屏竖屏

// 监听屏幕
            window.addEventListener('orientationchange', function() {
                let orientation = window.orientation;
                console.log("orientation", orientation);

                switch(orientation)
                {
                    case 90:
                        console.log("横屏")
                        break;
                    default:
                        console.log("竖屏");
                }
                
            })

 

posted @ 2022-11-27 13:03  sanyekui  阅读(31)  评论(0编辑  收藏  举报