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

原文地址:https://www.cnblogs.com/Forever-0209/p/13229283.html