【转】JavaScript 判断iPhone X Series机型的方法
作者:互联网
https://www.jb51.net/article/155482.htm
const isIphonex = () => { // X XS, XS Max, XR const xSeriesConfig = [ { devicePixelRatio: 3, width: 375, height: 812, }, { devicePixelRatio: 3, width: 414, height: 896, }, { devicePixelRatio: 2, width: 414, height: 896, }, ]; // 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; }
标签:const,devicePixelRatio,Series,JavaScript,height,width,window,iPhone,item 来源: https://www.cnblogs.com/wrongcode/p/12073940.html