Foreword:
How to judge whether it is a developer tool or Android or ios in a small program, because some codes need to be processed in a special environment, so I will share it here.
Official method:
wx.getSystemInfo and wx.getSystemInfoSync both obtain system information, but the difference between asynchronous and synchronous wx.getSystemInfo(Object object) | WeChat Open Documentation WeChat Developer Platform Documentation https://developers.weixin.qq.com/minigame/ dev/api/base/system/wx.getSystemInfo.html
How to judge whether it is a developer tool or other in the applet?
// 开发者工具
const platform = wx.getSystemInfoSync().platform
//开发者工具
if(platform === "devtools"){}
//ios 包含 iPhone、iPad
if(platform === "ios"){}
//安卓
if(platform === "android"){}
api:
How does the applet obtain information such as the width and height of the mobile phone?
wx.getSystemInfoSync().windowWidth; //获取设备屏幕宽度
wx.getSystemInfoSync().windowWidth; //获取设备屏幕宽度
api: