Created
November 28, 2019 06:27
-
-
Save fancyboynet/947f19c7145fc8550ed8d9d5ad02581f to your computer and use it in GitHub Desktop.
判断手机是否竖屏
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function isPortrait () { | |
if (!/ios|iphone|ipad|Macintosh/i.test(window.navigator.userAgent)) { // iphone 只会保留竖屏的宽高 | |
return window.screen.width < window.screen.height | |
} | |
return (window.orientation === 180 || window.orientation === 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment