Blogger Information
Blog 56
fans 7
comment 11
visits 221198
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
微信小程序判断屏幕大小是否长屏
樂成的开发笔记
Original
628 people have browsed it

app.js

// app.js App({ onLaunch(e) { // 判断屏幕大小 var judgeBigScreen = () => { let result = false; const res = wx.getSystemInfoSync(); const rate = res.windowHeight / res.windowWidth; let limit = res.windowHeight == res.screenHeight ? 1.8 : 1.65; // 临界判断值 if (rate > limit) result = true; return result; } this.globalData.judgeBigScreen = judgeBigScreen(); }, globalData: { judgeBigScreen:false, } })

定义好之后在需要判断的页面使用即可

var app = getApp() Page({ data: { }, onLoad(options) { console.log('是否为长屏', app.globalData.judgeBigScreen); }, })


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply withNews Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!