Back to Uni App

Get System Info

docs/api/get-system-info.md

2.3.354.3 KB
Original Source
<!-- ## uni.getSystemInfo(options) @getsysteminfo -->

::: sourceCode

uni.getSystemInfo(options) @getsysteminfo

GitCode: https://gitcode.com/dcloud/uni-api/tree/alpha/uni_modules/uni-getSystemInfo

GitHub: https://github.com/dcloudio/uni-api/tree/alpha/uni_modules/uni-getSystemInfo

:::

HBuilderX4.13-alpha版本,uniPlatform属性在 app 平台临时调整过,由 app 改为 app-androidapp-ios,HBuilderX 4.14-alpha版本已回撤此调整。如果开发者使用HBuilderX4.13-alpha版发布项目时使用了uni-id-common、uni-id、uni-id-pages或uni-id-pages-x,则需要分别升级到如下版本来兼容此次临时调整:[email protected][email protected][email protected][email protected]

异步获取系统信息

getSystemInfo 兼容性

Web微信小程序AndroidiOSHarmonyOSHarmonyOS(Vapor)
4.04.413.94.114.615.0

uni-app 提供了异步(uni.getSystemInfo)和同步(uni.getSystemInfoSync)的2个API获取系统信息。

按照运行环境层级排序,从底层向上,systemInfo有6个概念:

  • device:运行应用的设备,如iphone、huawei
  • os:设备的操作系统,如 ios、andriod、windows、mac、linux
  • rom:基于操作系统的定制,Android系统特有概念,如miui、鸿蒙
  • host:运行应用的宿主程序,即OS和应用之间的运行环境,如浏览器、微信等小程序宿主、集成uniMPSDK的App
  • uni:uni-app框架相关的信息,如uni-app框架的编译器版本、运行时版本
  • app:开发者的应用相关的信息,如应用名称、版本

因本API涉及的信息越来越多,查询速度会逐渐变慢。由此拆解分出3个新API,uni.getDeviceInfouni.getAppBaseInfouni.getWindowInfo。新API包含的信息更多。

微信小程序已经不推荐使用getSystemInfo,建议使用上述分拆的3个API。

参数

名称类型必填默认值兼容性描述
optionsGetSystemInfoOptions-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -

options 的属性描述

名称类型必备默认值兼容性描述
success(result: GetSystemInfoResult) => voidnullWeb: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -接口调用成功的回调函数
fail(result: GetSystemInfoFail) => voidnullWeb: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -接口调用失败的回调函数
complete(result: any) => voidnullWeb: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -接口调用结束的回调函数(调用成功、失败都会执行)

GetSystemInfoResult 的属性值 @getsysteminforesult-values

名称类型必备默认值兼容性描述
SDKVersionstring-Web: x; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x客户端基础库版本
appIdstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0manifest.json 中应用appid。
appLanguagestring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0应用设置的语言。
appNamestring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0manifest.json 中应用名称。
appVersionstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0manifest.json 中应用版本名称。
appVersionCodestring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0manifest.json 中应用版本号。
appWgtVersionstring-Web: x; 微信小程序: x; Android: x; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0应用资源(wgt)的版本名称。
browserNamestring-Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x浏览器名称。App 端是系统 webview 的名字,比如 wkwebview、chrome。小程序端为空
browserVersionstring-Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x浏览器版本、webview 版本。
deviceIdstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备 ID
deviceBrandstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备品牌。如:applehuawei
deviceModelstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备型号
deviceTypestring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备类型。
devicePixelRationumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备像素比
deviceOrientationstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备方向。
osNamestring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0系统名称
osVersionstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0操作系统版本。如 ios 版本,andriod 版本
osLanguagestring-Web: 4.0; 微信小程序: -; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0操作系统语言
osThemestring-Web: x; 微信小程序: x; Android: √; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0操作系统主题
screenWidthnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0屏幕宽度,单位为px
screenHeightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0屏幕高度,单位为px
statusBarHeightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0状态栏的高度,单位为px
safeAreaSafeArea-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0在竖屏正方向下的安全区域
safeAreaInsetsSafeAreaInsets-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0在竖屏正方向下的安全区域插入位置
uastring-Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x用户标识。小程序端为空
uniCompilerVersionstring-Web: 4.18; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0uni 编译器版本。
uniPlatformstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0uni-app 运行平台,与条件编译平台相同。
uniRuntimeVersionstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0uni 运行时版本。
uniCompilerVersionCodenumber-Web: 4.18; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0uni 编译器版本号。
uniRuntimeVersionCodenumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0uni 运行时版本号。
romNamestring-Web: x; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0rom 名称。Android 部分机型获取不到值。iOS 恒为 ios
romVersionstring-Web: x; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0rom 版本号。Android 部分机型获取不到值。iOS 为操作系统版本号(同 osVersion)。
windowWidthnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0可使用窗口宽度,单位为px
windowHeightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0可使用窗口高度,单位为px
windowTopnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0内容区域距离顶部的距离(同CSS变量 --window-top),单位为px
windowBottomnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0内容区域距离底部的距离(同CSS变量 --window-bottom),单位为px
osAndroidAPILevelnumber-Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: xAndroid 系统API库的版本。
osHarmonySDKAPIVersionnumber-Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0鸿蒙系统软件API版本
osHarmonyDisplayVersionstring-Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0产品版本,关于本机信息内的软件版本
appThemestring-Web: x; 微信小程序: x; Android: 4.18; iOS: 4.18; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0当前App的主题
hostThemestring-Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主主题(仅 web、微信小程序支持)
hostVersionstring-Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主版本(仅 web、微信小程序支持)
hostLanguagestring-Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主语言(仅 web、微信小程序支持)
hostNamestring-Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主名称(仅 web、微信小程序支持)
hostSDKVersionstring-Web: x; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主 SDKVersion(仅 web、微信小程序支持)
hostFontSizeSettingnumber-Web: x; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主字体大小设置(仅 web、微信小程序支持)
albumAuthorizedboolean-Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -需要基础库: 2.6.0

允许微信使用相册的开关(仅 iOS 有效) | | benchmarkLevel | number | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 1.8.0

设备性能等级(仅 Android)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好) 注意:性能等级当前仅反馈真机机型,暂不支持 IDE 模拟器机型 | | bluetoothEnabled | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

蓝牙的系统开关 | | cameraAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信使用摄像头的开关 | | enableDebug | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.15.0

是否已打开调试。可通过右上角菜单或 uni.setEnableDebug 打开调试。 | | fontSizeSetting | number | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 1.5.0

用户字体大小(单位px)。以微信客户端「我-设置-通用-字体大小」中的设置为准 | | host | GetSystemInfoResultHost | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.12.3

当前小程序运行的宿主环境 | | locationAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信使用定位的开关 | | locationEnabled | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

地理位置的系统开关 | | locationReducedAccuracy | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | true 表示模糊定位,false 表示精确定位,仅 iOS 支持 | | microphoneAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信使用麦克风的开关 | | notificationAlertAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信通知带有提醒的开关(仅 iOS 有效) | | notificationAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信通知的开关 | | notificationBadgeAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信通知带有标记的开关(仅 iOS 有效) | | notificationSoundAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信通知带有声音的开关(仅 iOS 有效) | | phoneCalendarAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.19.3

允许微信使用日历的开关 | | wifiEnabled | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

Wi-Fi 的系统开关 | | theme | string | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.11.0

系统当前主题,取值为lightdark,全局配置"darkmode":true时才能获取,否则为 undefined (不支持小游戏)

可选值:

  • 'dark': 深色主题;
  • 'light': 浅色主题; | | brand | string | 是 | - | Web: x; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 手机品牌。 已废弃,仅为了向下兼容保留 | | language | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 程序设置的语言 已废弃,仅为了向下兼容保留 | | model | string | 否 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 手机型号 已废弃,仅为了向下兼容保留 | | pixelRatio | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 设备像素比 已废弃,仅为了向下兼容保留 | | platform | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 客户端平台 已废弃,仅为了向下兼容保留 | | system | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 操作系统版本 已废弃,仅为了向下兼容保留 | | uniCompileVersion | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | uni 编译器版本。 已废弃,仅为了向下兼容保留 | | uniCompileVersionCode | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | uni 编译器版本号。 已废弃,仅为了向下兼容保留 | | version | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 引擎版本号。 已废弃,仅为了向下兼容保留 |

deviceType 的属性描述

合法值兼容性描述
phoneWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
padWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
tvWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
watchWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
pcWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
undefinedWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
carWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
vrWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
applianceWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --

deviceOrientation 的属性描述

合法值兼容性描述
portraitWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -纵向
landscapeWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -横向

osName 的属性描述

合法值兼容性描述
iosWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
androidWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
harmonyosWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
macosWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
windowsWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
linuxWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --

osTheme 的属性描述

合法值兼容性描述
lightWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
darkWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --

safeArea 的属性描述

名称类型必备默认值兼容性描述
leftnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域左上角横坐标,单位为px
rightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域右下角横坐标,单位为px
topnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域左上角纵坐标,单位为px
bottomnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域右下角纵坐标,单位为px
widthnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域的宽度,单位为px
heightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域的高度,单位为px

safeAreaInsets 的属性描述

名称类型必备默认值兼容性描述
leftnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域左侧插入位置(距离左边边界距离),单位为px
rightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域右侧插入位置(距离右边边界距离),单位为px
topnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区顶部插入位置(距离顶部边界距离),单位为px
bottomnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域底部插入位置(距离底部边界距离),单位为px

uniPlatform 的属性描述

合法值兼容性描述
appWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
webWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-weixinWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-alipayWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-baiduWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-toutiaoWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-larkWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-qqWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-kuaishouWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-jdWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-360Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
quickapp-webviewWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
quickapp-webview-unionWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
quickapp-webview-huaweiWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --

appTheme 的属性描述

合法值兼容性描述
lightWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
darkWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
autoWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --

hostTheme 的属性描述

合法值兼容性描述
lightWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
darkWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --

host 的属性描述

名称类型必备默认值兼容性描述
appIdstring-Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -宿主 app 对应的 appId

theme 的属性描述

合法值兼容性描述
darkWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
lightWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --

platform 的属性描述

合法值兼容性描述
iosWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
androidWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
harmonyosWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
macWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
windowsWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
linuxWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
ohosWeb: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: --
devtoolsWeb: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: --

GetSystemInfoFail 的属性值 @getsysteminfofail-values

名称类型必备默认值兼容性描述
errSubjectstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -统一错误主题(模块)名称
errCodenumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -统一错误码
errMsgstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -统一错误描述信息
dataany-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -错误信息中包含的数据
causeError-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -源错误信息,可以包含多个错误,详见SourceError
namestring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -
messagestring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -

::: warning 注意事项

  • appTheme如取值为auto,代表跟随系统。此时需查询osTheme获取当前到底是light还是dark。
  • 获取OAID、AndroidID等其他设备信息,见插件市场
  • Android端的windowHeight属性是有时机的考量的,如果在全局作用域获取windowHeight,有可能当前Activity还未加载,所以导航栏和Tabbar的高度是不会计算进去的,稳妥起见,建议在onReady或者onPageShow内获取windowheight
  • windowHeight属性是依赖于调用Api时栈顶Page的,比如延迟获取windowHeight,很可能页面已经切换了,这时候获取的高度是新的页面的。
  • 4.25开始,Android端安全区域top调整为手机状态栏高度 :::

romName 返回值说明 @romname

解释
MIUI小米
EMUI华为
HarmonyOS华为鸿蒙
Magic OS荣耀
ColorOSoppo
Funtouch OSvivo
FLymeOS魅族
SmartisanOS锤子

注意:不同rom的版本号规则不同,比如MIUI版本号是V130,而HarmonyOS的版本号是2.0.0

hostName 返回值说明 @hostname

解释
WeChat微信
wxwork微信企业版
百度宿主平台枚举值列表百度
alipay支付宝
amap高德
DINGTALK钉钉
UCUC浏览器
QUARK夸克浏览器
AK阿里健康
YK优酷
抖音宿主平台枚举值列表抖音系列
qqQQ
KUAISHOU快手

示例

示例为hello uni-app x alpha分支,与最新HBuilderX Alpha版同步。与最新正式版同步的master分支示例另见 ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/get-system-info/get-system-info

appRedirect https://hellouniappx.dcloud.net.cn/appredirect.html?path=pages/API/get-system-info/get-system-info

示例

vue
<template>
  <!-- #ifdef APP -->
  <scroll-view style="flex: 1">
  <!-- #endif -->
    <view>
      <page-head :title="data.title"></page-head>
      <view class="uni-common-mt">
        <view class="uni-list">
          <view class="uni-list-cell" v-for="(item, _) in data.items" style="align-items: center">
            <view class="uni-pd">
              <view class="uni-label" style="width: 180px">{{
                item.label
              }}</view>
            </view>
            <view class="uni-list-cell-db">
              <text class="uni-list-cell-db-text">{{ item.value == '' ? '未获取' : item.value }}</text>
            </view>
          </view>
        </view>
        <view class="uni-padding-wrap">
          <view class="uni-btn-v">
            <button type="primary" @tap="getSystemInfoSync">
              同步获取设备系统信息
            </button>
            <button type="primary" @tap="getSystemInfo" style="margin-top: 20px;">
              异步获取设备系统信息
            </button>
          </view>
        </view>
      </view>
    </view>
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
</template>
<script setup lang="uts">
  type Item = {
    label : string,
    value : string,
  }

  type DataType = {
    title: string;
    items: Item[];
    screenHeightAtReady: number;
    jest_result: boolean;
  }

  let globalScreenHeight = 0
  try {
    globalScreenHeight = uni.getWindowInfo().screenHeight
  } catch (e) {
    // 兼容本地测试
    console.error(e)
  }

  const data = reactive({
    title: 'getSystemInfo',
    items: [] as Item[],
    screenHeightAtReady: 0,
    jest_result: false,
  } as DataType)

  onReady(() => {
    data.screenHeightAtReady = uni.getSystemInfoSync().screenHeight
    console.log(`全局获取屏幕高度: ${globalScreenHeight}  onReady内获取屏幕高度: ${data.screenHeightAtReady}`);
  })

  const getSystemInfo = () => {
    uni.getSystemInfo({
      success: (res) => {
        data.items = [] as Item[];
        const res_str = JSON.stringify(res);
        const res_obj = JSON.parseObject(res_str);
        const res_map = res_obj!.toMap();
        let keys = [] as string[]
        res_map.forEach((_, key) => {
          keys.push(key);
        });
        keys.sort().forEach(key => {
          const value = res[key];
          if (value != null) {
            const item = {
              label: key,
              value: "" + ((typeof value == "object") ? JSON.stringify(value) : value)
            } as Item;
            data.items.push(item);
          }
        });
      },
    })
  }

  const getSystemInfoSync = () => {
    data.items = [] as Item[];
    const res = uni.getSystemInfoSync()
    const res_str = JSON.stringify(res);
    const res_obj = JSON.parseObject(res_str);
    const res_map = res_obj!.toMap();
    let keys = [] as string[]
    res_map.forEach((_, key) => {
      keys.push(key);
    });
    keys.sort().forEach(key => {
      const value = res[key];
      if (value != null) {
        const item = {
          label: key,
          value: "" + ((typeof value == "object") ? JSON.stringify(value) : value)
        } as Item;
        data.items.push(item);
      }
    });
  }

  //自动化测试例专用
  const jest_getSystemInfo = () : GetSystemInfoResult => {
    return uni.getSystemInfoSync();
  }

  const jest_getScreenHeight_at_different_stages = () => {
    data.jest_result = (globalScreenHeight == data.screenHeightAtReady)
  }

  defineExpose({
    data,
    jest_getSystemInfo,
    jest_getScreenHeight_at_different_stages
  })
</script>

<style>
  .uni-pd {
    padding-left: 15px;
  }
</style>

:::

参见

<!-- ## uni.getSystemInfoSync() @getsysteminfosync -->

::: sourceCode

uni.getSystemInfoSync() @getsysteminfosync

GitCode: https://gitcode.com/dcloud/uni-api/tree/alpha/uni_modules/uni-getSystemInfo

GitHub: https://github.com/dcloudio/uni-api/tree/alpha/uni_modules/uni-getSystemInfo

:::

同步获取系统信息

本API是同步API,仅为上面异步API的同步形式,返回值内容没有区别。但由于本API涉及的查询内容较多,耗时长,一般情况下不推荐同步获取。
如果希望使用同步方式,推荐使用分拆后的API:uni.getDeviceInfouni.getWindowInfouni.getAppBaseInfo

getSystemInfoSync 兼容性

Web微信小程序AndroidiOSHarmonyOSHarmonyOS(Vapor)
4.04.413.94.114.615.0

返回值

类型
GetSystemInfoResult

GetSystemInfoResult 的属性描述

名称类型必备默认值兼容性描述
SDKVersionstring-Web: x; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x客户端基础库版本
appIdstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0manifest.json 中应用appid。
appLanguagestring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0应用设置的语言。
appNamestring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0manifest.json 中应用名称。
appVersionstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0manifest.json 中应用版本名称。
appVersionCodestring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0manifest.json 中应用版本号。
appWgtVersionstring-Web: x; 微信小程序: x; Android: x; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0应用资源(wgt)的版本名称。
browserNamestring-Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x浏览器名称。App 端是系统 webview 的名字,比如 wkwebview、chrome。小程序端为空
browserVersionstring-Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x浏览器版本、webview 版本。
deviceIdstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备 ID
deviceBrandstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备品牌。如:applehuawei
deviceModelstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备型号
deviceTypestring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备类型。
devicePixelRationumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备像素比
deviceOrientationstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0设备方向。
osNamestring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0系统名称
osVersionstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0操作系统版本。如 ios 版本,andriod 版本
osLanguagestring-Web: 4.0; 微信小程序: -; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0操作系统语言
osThemestring-Web: x; 微信小程序: x; Android: √; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0操作系统主题
screenWidthnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0屏幕宽度,单位为px
screenHeightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0屏幕高度,单位为px
statusBarHeightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0状态栏的高度,单位为px
safeAreaSafeArea-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0在竖屏正方向下的安全区域
safeAreaInsetsSafeAreaInsets-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0在竖屏正方向下的安全区域插入位置
uastring-Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x用户标识。小程序端为空
uniCompilerVersionstring-Web: 4.18; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0uni 编译器版本。
uniPlatformstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0uni-app 运行平台,与条件编译平台相同。
uniRuntimeVersionstring-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0uni 运行时版本。
uniCompilerVersionCodenumber-Web: 4.18; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0uni 编译器版本号。
uniRuntimeVersionCodenumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0uni 运行时版本号。
romNamestring-Web: x; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0rom 名称。Android 部分机型获取不到值。iOS 恒为 ios
romVersionstring-Web: x; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0rom 版本号。Android 部分机型获取不到值。iOS 为操作系统版本号(同 osVersion)。
windowWidthnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0可使用窗口宽度,单位为px
windowHeightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0可使用窗口高度,单位为px
windowTopnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0内容区域距离顶部的距离(同CSS变量 --window-top),单位为px
windowBottomnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0内容区域距离底部的距离(同CSS变量 --window-bottom),单位为px
osAndroidAPILevelnumber-Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: xAndroid 系统API库的版本。
osHarmonySDKAPIVersionnumber-Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0鸿蒙系统软件API版本
osHarmonyDisplayVersionstring-Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0产品版本,关于本机信息内的软件版本
appThemestring-Web: x; 微信小程序: x; Android: 4.18; iOS: 4.18; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0当前App的主题
hostThemestring-Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主主题(仅 web、微信小程序支持)
hostVersionstring-Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主版本(仅 web、微信小程序支持)
hostLanguagestring-Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主语言(仅 web、微信小程序支持)
hostNamestring-Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主名称(仅 web、微信小程序支持)
hostSDKVersionstring-Web: x; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主 SDKVersion(仅 web、微信小程序支持)
hostFontSizeSettingnumber-Web: x; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x宿主字体大小设置(仅 web、微信小程序支持)
albumAuthorizedboolean-Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -需要基础库: 2.6.0

允许微信使用相册的开关(仅 iOS 有效) | | benchmarkLevel | number | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 1.8.0

设备性能等级(仅 Android)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好) 注意:性能等级当前仅反馈真机机型,暂不支持 IDE 模拟器机型 | | bluetoothEnabled | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

蓝牙的系统开关 | | cameraAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信使用摄像头的开关 | | enableDebug | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.15.0

是否已打开调试。可通过右上角菜单或 uni.setEnableDebug 打开调试。 | | fontSizeSetting | number | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 1.5.0

用户字体大小(单位px)。以微信客户端「我-设置-通用-字体大小」中的设置为准 | | host | GetSystemInfoResultHost | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.12.3

当前小程序运行的宿主环境 | | locationAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信使用定位的开关 | | locationEnabled | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

地理位置的系统开关 | | locationReducedAccuracy | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | true 表示模糊定位,false 表示精确定位,仅 iOS 支持 | | microphoneAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信使用麦克风的开关 | | notificationAlertAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信通知带有提醒的开关(仅 iOS 有效) | | notificationAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信通知的开关 | | notificationBadgeAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信通知带有标记的开关(仅 iOS 有效) | | notificationSoundAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

允许微信通知带有声音的开关(仅 iOS 有效) | | phoneCalendarAuthorized | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.19.3

允许微信使用日历的开关 | | wifiEnabled | boolean | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.6.0

Wi-Fi 的系统开关 | | theme | string | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 需要基础库: 2.11.0

系统当前主题,取值为lightdark,全局配置"darkmode":true时才能获取,否则为 undefined (不支持小游戏)

可选值:

  • 'dark': 深色主题;
  • 'light': 浅色主题; | | brand | string | 是 | - | Web: x; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 手机品牌。 已废弃,仅为了向下兼容保留 | | language | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 程序设置的语言 已废弃,仅为了向下兼容保留 | | model | string | 否 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 手机型号 已废弃,仅为了向下兼容保留 | | pixelRatio | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 设备像素比 已废弃,仅为了向下兼容保留 | | platform | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 客户端平台 已废弃,仅为了向下兼容保留 | | system | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 操作系统版本 已废弃,仅为了向下兼容保留 | | uniCompileVersion | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | uni 编译器版本。 已废弃,仅为了向下兼容保留 | | uniCompileVersionCode | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | uni 编译器版本号。 已废弃,仅为了向下兼容保留 | | version | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 引擎版本号。 已废弃,仅为了向下兼容保留 |
deviceType 的属性描述
合法值兼容性描述
phoneWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
padWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
tvWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
watchWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
pcWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
nullWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
carWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
vrWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
applianceWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
deviceOrientation 的属性描述
合法值兼容性描述
portraitWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -纵向
landscapeWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: -横向
osName 的属性描述
合法值兼容性描述
iosWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
androidWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
harmonyosWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
macosWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
windowsWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
linuxWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
osTheme 的属性描述
合法值兼容性描述
lightWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
darkWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
safeArea 的属性描述
名称类型必备默认值兼容性描述
leftnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域左上角横坐标,单位为px
rightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域右下角横坐标,单位为px
topnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域左上角纵坐标,单位为px
bottomnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域右下角纵坐标,单位为px
widthnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域的宽度,单位为px
heightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域的高度,单位为px
safeAreaInsets 的属性描述
名称类型必备默认值兼容性描述
leftnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域左侧插入位置(距离左边边界距离),单位为px
rightnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域右侧插入位置(距离右边边界距离),单位为px
topnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区顶部插入位置(距离顶部边界距离),单位为px
bottomnumber-Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0安全区域底部插入位置(距离底部边界距离),单位为px
uniPlatform 的属性描述
合法值兼容性描述
appWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
webWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-weixinWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-alipayWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-baiduWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-toutiaoWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-larkWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-qqWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-kuaishouWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-jdWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
mp-360Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
quickapp-webviewWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
quickapp-webview-unionWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
quickapp-webview-huaweiWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
appTheme 的属性描述
合法值兼容性描述
lightWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
darkWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
autoWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
hostTheme 的属性描述
合法值兼容性描述
lightWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
darkWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
host 的属性描述
名称类型必备默认值兼容性描述
appIdstring-Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -宿主 app 对应的 appId
theme 的属性描述
合法值兼容性描述
darkWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
lightWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
platform 的属性描述
合法值兼容性描述
iosWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
androidWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
harmonyosWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
macWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
windowsWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
linuxWeb: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: --
ohosWeb: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: --
devtoolsWeb: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: --
<!-- UTSAPIJSON.getSystemInfoSync.example -->

参见

通用类型

GeneralCallbackResult

名称类型必备默认值兼容性描述
errMsgstring-Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -错误信息