1234567891011121314151617181920212223242526272829303132
handleScreenRatio () { // 获取系统信息 const system = wx.getSystemInfoSync(); const width = system.screenWidth * system.devicePixelRatio; const height = system.screenHeight * system.devicePixelRatio; // 常见的比例,需自己添加更多 const list = [ [20, 9], [19.5, 9], [18, 9], [16, 10], [16, 9], ]; // 分隔符 const seperator = ':'; for(let i in list) { let item = list[i]; // 先计算出屏幕大小除当前比例,结果的的绝对值会不会在我们的容错值范围内。 if(Math.abs(~~(height / item[0]) - ~~(width / item[1])) < 3) { return item.join(seperator); } } // wx.getRealtimeLogManager().info('未知屏幕比例', system); return '未知';},
hongfs.ʕ◔ϖ◔ʔ
2023 新时代的广州传统美德我在绿灯的人行道上礼让电动车
文章
174
分类
13