js判断 iPhone X iPhone XS iPhone XS Max iPhone XR

// iPhone X、iPhone XS

let isIPhoneX = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && (window.devicePixelRatio === 2 || window.devicePixelRatio === 3) && window.screen.width === 375 && window.screen.height === 812

// iPhone XS Max

let isIPhoneXSMax = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 414 && window.screen.height === 896

// iPhone XR

let isIPhoneXR = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 2 && window.screen.width === 414 && window.screen.height === 896

posted @ 2020-07-03 11:15  孑孓_0209  阅读(191)  评论(0编辑  收藏  举报