参考资料:https://useyourloaf.com/blog/iphone-12-screen-sizes/
export const hasBottomToolBar = () => { return ( /iphone/gi.test(navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio >= 2 && window.screen.height >= 812 ) }
export function isIphonex() { // 判断是不是X类型手机 // X XS, XS Max, XR,11, 11pro,11pro max,12mini,12, 12 pro,12 pro max const xSeriesConfig = [ { devicePixelRatio: 3, width: 375, height: 812, }, { devicePixelRatio: 3, width: 414, height: 896, }, { devicePixelRatio: 2, width: 414, height: 896, }, { devicePixelRatio: 3, width: 315, height: 812, }, { devicePixelRatio: 3, width: 390, height: 844, }, { devicePixelRatio: 3, width: 428, height: 926, } ]; // h5 if (typeof window !== 'undefined' && window) { const isIOS = /iphone/gi.test(window.navigator.userAgent); if (!isIOS) return false; const { devicePixelRatio, screen } = window; const { width, height } = screen; return xSeriesConfig.some(item => item.devicePixelRatio === devicePixelRatio && item.width === width && item.height === height); } return false; }
标签:bar,devicePixelRatio,height,width,window,&&,touch,const,js From: https://www.cnblogs.com/ygunoil/p/16935975.html