Skip to content

Instantly share code, notes, and snippets.

@fancyboynet
Created November 28, 2019 06:27
Show Gist options
  • Save fancyboynet/947f19c7145fc8550ed8d9d5ad02581f to your computer and use it in GitHub Desktop.
Save fancyboynet/947f19c7145fc8550ed8d9d5ad02581f to your computer and use it in GitHub Desktop.
判断手机是否竖屏
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