代码

onLoad() {
	let that = this;
	 wx.getSystemInfo({
		 success:function(res){
			 console.log("wx.getSystemInfo")
			 console.log(res)
			 if(res.platform=="ios"){
				that.isIOS = !that.isIOS; 
			 }
		 }
	 });
}

如果是安卓,返回如下

在这里插入图片描述

如果是iOS返回如下

SDKVersion: "2.17.0"
albumAuthorized: true
batteryLevel: 27.000001907348633
benchmarkLevel: 15
bluetoothEnabled: true
brand: "iPhone"
cameraAuthorized: true
deviceOrientation: "portrait"
devicePixelRatio: 3
enableDebug: false
errMsg: "getSystemInfo:ok"
fontSizeSetting: 17
host: {env: "WeChat", appId: "", version: 402654252}
language: "zh_CN"
locationAuthorized: true
locationEnabled: true
locationReducedAccuracy: false
microphoneAuthorized: true
model: "iPhone 7 Plus<iPhone9,2>"
notificationAlertAuthorized: true
notificationAuthorized: true
notificationBadgeAuthorized: true
notificationSoundAuthorized: true
pixelRatio: 3
platform: "ios"
safeArea: {bottom: 736, height: 716, top: 20, width: 414, left: 0,}
screenHeight: 736
screenTop: 0
screenWidth: 414
statusBarHeight: 20
system: "iOS 13.7"
version: "8.0.4"
wifiEnabled: true
windowHeight: 672
windowWidth: 414

相关资料

wx.getSystemInfo(Object object)

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐