docs/api/get-system-info.md
::: sourceCode
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-android、app-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]
异步获取系统信息
| Web | 微信小程序 | Android | iOS | HarmonyOS | HarmonyOS(Vapor) |
|---|---|---|---|---|---|
| 4.0 | 4.41 | 3.9 | 4.11 | 4.61 | 5.0 |
uni-app 提供了异步(uni.getSystemInfo)和同步(uni.getSystemInfoSync)的2个API获取系统信息。
按照运行环境层级排序,从底层向上,systemInfo有6个概念:
device:运行应用的设备,如iphone、huaweios:设备的操作系统,如 ios、andriod、windows、mac、linuxrom:基于操作系统的定制,Android系统特有概念,如miui、鸿蒙host:运行应用的宿主程序,即OS和应用之间的运行环境,如浏览器、微信等小程序宿主、集成uniMPSDK的Appuni:uni-app框架相关的信息,如uni-app框架的编译器版本、运行时版本app:开发者的应用相关的信息,如应用名称、版本因本API涉及的信息越来越多,查询速度会逐渐变慢。由此拆解分出3个新API,uni.getDeviceInfo、uni.getAppBaseInfo、uni.getWindowInfo。新API包含的信息更多。
微信小程序已经不推荐使用getSystemInfo,建议使用上述分拆的3个API。
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| options | GetSystemInfoOptions | 是 | - | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| success | (result: GetSystemInfoResult) => void | 否 | null | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 接口调用成功的回调函数 |
| fail | (result: GetSystemInfoFail) => void | 否 | null | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 接口调用失败的回调函数 |
| complete | (result: any) => void | 否 | null | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 接口调用结束的回调函数(调用成功、失败都会执行) |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| SDKVersion | string | 是 | - | Web: x; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 客户端基础库版本 |
| appId | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | manifest.json 中应用appid。 |
| appLanguage | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 应用设置的语言。 |
| appName | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | manifest.json 中应用名称。 |
| appVersion | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | manifest.json 中应用版本名称。 |
| appVersionCode | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | manifest.json 中应用版本号。 |
| appWgtVersion | string | 否 | - | Web: x; 微信小程序: x; Android: x; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 应用资源(wgt)的版本名称。 |
| browserName | string | 是 | - | Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x | 浏览器名称。App 端是系统 webview 的名字,比如 wkwebview、chrome。小程序端为空 |
| browserVersion | string | 是 | - | Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x | 浏览器版本、webview 版本。 |
| deviceId | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备 ID |
| deviceBrand | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备品牌。如:apple、huawei。 |
| deviceModel | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备型号 |
| deviceType | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备类型。 |
| devicePixelRatio | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备像素比 |
| deviceOrientation | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备方向。 |
| osName | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 系统名称 |
| osVersion | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 操作系统版本。如 ios 版本,andriod 版本 |
| osLanguage | string | 是 | - | Web: 4.0; 微信小程序: -; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 操作系统语言 |
| osTheme | string | 否 | - | Web: x; 微信小程序: x; Android: √; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 操作系统主题 |
| screenWidth | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 屏幕宽度,单位为px |
| screenHeight | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 屏幕高度,单位为px |
| statusBarHeight | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 状态栏的高度,单位为px |
| safeArea | SafeArea | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 在竖屏正方向下的安全区域 |
| safeAreaInsets | SafeAreaInsets | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 在竖屏正方向下的安全区域插入位置 |
| ua | string | 是 | - | Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x | 用户标识。小程序端为空 |
| uniCompilerVersion | string | 是 | - | Web: 4.18; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | uni 编译器版本。 |
| uniPlatform | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | uni-app 运行平台,与条件编译平台相同。 |
| uniRuntimeVersion | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | uni 运行时版本。 |
| uniCompilerVersionCode | number | 是 | - | Web: 4.18; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | uni 编译器版本号。 |
| uniRuntimeVersionCode | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | uni 运行时版本号。 |
| romName | string | 是 | - | Web: x; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | rom 名称。Android 部分机型获取不到值。iOS 恒为 ios |
| romVersion | string | 是 | - | Web: x; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | rom 版本号。Android 部分机型获取不到值。iOS 为操作系统版本号(同 osVersion)。 |
| windowWidth | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 可使用窗口宽度,单位为px |
| windowHeight | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 可使用窗口高度,单位为px |
| windowTop | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 内容区域距离顶部的距离(同CSS变量 --window-top),单位为px |
| windowBottom | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 内容区域距离底部的距离(同CSS变量 --window-bottom),单位为px |
| osAndroidAPILevel | number | 否 | - | Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: x | Android 系统API库的版本。 |
| osHarmonySDKAPIVersion | number | 否 | - | Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 鸿蒙系统软件API版本 |
| osHarmonyDisplayVersion | string | 否 | - | Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 产品版本,关于本机信息内的软件版本 |
| appTheme | string | 否 | - | Web: x; 微信小程序: x; Android: 4.18; iOS: 4.18; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 当前App的主题 |
| hostTheme | string | 否 | - | Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主主题(仅 web、微信小程序支持) |
| hostVersion | string | 否 | - | Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主版本(仅 web、微信小程序支持) |
| hostLanguage | string | 否 | - | Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主语言(仅 web、微信小程序支持) |
| hostName | string | 否 | - | Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主名称(仅 web、微信小程序支持) |
| hostSDKVersion | string | 否 | - | Web: x; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主 SDKVersion(仅 web、微信小程序支持) |
| hostFontSizeSetting | number | 否 | - | Web: x; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主字体大小设置(仅 web、微信小程序支持) |
| albumAuthorized | boolean | 否 | - | 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
系统当前主题,取值为light或dark,全局配置"darkmode":true时才能获取,否则为 undefined (不支持小游戏)
可选值:
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| phone | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| pad | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| tv | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| watch | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| pc | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| undefined | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| car | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| vr | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| appliance | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| portrait | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 纵向 |
| landscape | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 横向 |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| ios | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| android | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| harmonyos | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| macos | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| windows | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| linux | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| light | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| dark | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| left | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域左上角横坐标,单位为px |
| right | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域右下角横坐标,单位为px |
| top | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域左上角纵坐标,单位为px |
| bottom | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域右下角纵坐标,单位为px |
| width | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域的宽度,单位为px |
| height | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域的高度,单位为px |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| left | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域左侧插入位置(距离左边边界距离),单位为px |
| right | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域右侧插入位置(距离右边边界距离),单位为px |
| top | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区顶部插入位置(距离顶部边界距离),单位为px |
| bottom | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域底部插入位置(距离底部边界距离),单位为px |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| app | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| web | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-weixin | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-alipay | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-baidu | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-toutiao | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-lark | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-qq | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-kuaishou | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-jd | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-360 | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| quickapp-webview | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| quickapp-webview-union | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| quickapp-webview-huawei | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| light | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| dark | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| auto | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| light | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| dark | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| appId | string | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 宿主 app 对应的 appId |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| dark | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| light | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| ios | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| android | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| harmonyos | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mac | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| windows | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| linux | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| ohos | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | - |
| devtools | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | - |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| errSubject | string | 是 | - | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 统一错误主题(模块)名称 |
| errCode | number | 是 | - | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 统一错误码 |
| errMsg | string | 是 | - | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 统一错误描述信息 |
| data | any | 否 | - | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 错误信息中包含的数据 |
| cause | Error | 否 | - | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 源错误信息,可以包含多个错误,详见SourceError |
| name | string | 是 | - | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | |
| message | string | 是 | - | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - |
::: warning 注意事项
auto,代表跟随系统。此时需查询osTheme获取当前到底是light还是dark。windowHeight属性是有时机的考量的,如果在全局作用域获取windowHeight,有可能当前Activity还未加载,所以导航栏和Tabbar的高度是不会计算进去的,稳妥起见,建议在onReady或者onPageShow内获取windowheight。windowHeight属性是依赖于调用Api时栈顶Page的,比如延迟获取windowHeight,很可能页面已经切换了,这时候获取的高度是新的页面的。| 值 | 解释 |
|---|---|
| MIUI | 小米 |
| EMUI | 华为 |
| HarmonyOS | 华为鸿蒙 |
| Magic OS | 荣耀 |
| ColorOS | oppo |
| Funtouch OS | vivo |
| FLymeOS | 魅族 |
| SmartisanOS | 锤子 |
注意:不同rom的版本号规则不同,比如MIUI版本号是V130,而HarmonyOS的版本号是2.0.0
| 值 | 解释 |
|---|---|
| 微信 | |
| wxwork | 微信企业版 |
| 百度宿主平台枚举值列表 | 百度 |
| alipay | 支付宝 |
| amap | 高德 |
| DINGTALK | 钉钉 |
| UC | UC浏览器 |
| QUARK | 夸克浏览器 |
| AK | 阿里健康 |
| YK | 优酷 |
| 抖音宿主平台枚举值列表 | 抖音系列 |
| 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
示例
<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>
:::
::: sourceCode
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.getDeviceInfo、uni.getWindowInfo、uni.getAppBaseInfo。
| Web | 微信小程序 | Android | iOS | HarmonyOS | HarmonyOS(Vapor) |
|---|---|---|---|---|---|
| 4.0 | 4.41 | 3.9 | 4.11 | 4.61 | 5.0 |
| 类型 |
|---|
| GetSystemInfoResult |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| SDKVersion | string | 是 | - | Web: x; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: x | 客户端基础库版本 |
| appId | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | manifest.json 中应用appid。 |
| appLanguage | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 应用设置的语言。 |
| appName | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | manifest.json 中应用名称。 |
| appVersion | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | manifest.json 中应用版本名称。 |
| appVersionCode | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | manifest.json 中应用版本号。 |
| appWgtVersion | string | 否 | - | Web: x; 微信小程序: x; Android: x; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 应用资源(wgt)的版本名称。 |
| browserName | string | 是 | - | Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x | 浏览器名称。App 端是系统 webview 的名字,比如 wkwebview、chrome。小程序端为空 |
| browserVersion | string | 是 | - | Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x | 浏览器版本、webview 版本。 |
| deviceId | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备 ID |
| deviceBrand | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备品牌。如:apple、huawei。 |
| deviceModel | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备型号 |
| deviceType | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备类型。 |
| devicePixelRatio | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备像素比 |
| deviceOrientation | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 设备方向。 |
| osName | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 系统名称 |
| osVersion | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 操作系统版本。如 ios 版本,andriod 版本 |
| osLanguage | string | 是 | - | Web: 4.0; 微信小程序: -; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 操作系统语言 |
| osTheme | string | 否 | - | Web: x; 微信小程序: x; Android: √; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 操作系统主题 |
| screenWidth | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 屏幕宽度,单位为px |
| screenHeight | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 屏幕高度,单位为px |
| statusBarHeight | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 状态栏的高度,单位为px |
| safeArea | SafeArea | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 在竖屏正方向下的安全区域 |
| safeAreaInsets | SafeAreaInsets | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 在竖屏正方向下的安全区域插入位置 |
| ua | string | 是 | - | Web: 4.0; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: x | 用户标识。小程序端为空 |
| uniCompilerVersion | string | 是 | - | Web: 4.18; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | uni 编译器版本。 |
| uniPlatform | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | uni-app 运行平台,与条件编译平台相同。 |
| uniRuntimeVersion | string | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | uni 运行时版本。 |
| uniCompilerVersionCode | number | 是 | - | Web: 4.18; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | uni 编译器版本号。 |
| uniRuntimeVersionCode | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | uni 运行时版本号。 |
| romName | string | 是 | - | Web: x; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | rom 名称。Android 部分机型获取不到值。iOS 恒为 ios |
| romVersion | string | 是 | - | Web: x; 微信小程序: x; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | rom 版本号。Android 部分机型获取不到值。iOS 为操作系统版本号(同 osVersion)。 |
| windowWidth | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 可使用窗口宽度,单位为px |
| windowHeight | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 可使用窗口高度,单位为px |
| windowTop | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 内容区域距离顶部的距离(同CSS变量 --window-top),单位为px |
| windowBottom | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 内容区域距离底部的距离(同CSS变量 --window-bottom),单位为px |
| osAndroidAPILevel | number | 否 | - | Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: x | Android 系统API库的版本。 |
| osHarmonySDKAPIVersion | number | 否 | - | Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 鸿蒙系统软件API版本 |
| osHarmonyDisplayVersion | string | 否 | - | Web: x; 微信小程序: x; Android: √; iOS: x; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 产品版本,关于本机信息内的软件版本 |
| appTheme | string | 否 | - | Web: x; 微信小程序: x; Android: 4.18; iOS: 4.18; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 当前App的主题 |
| hostTheme | string | 否 | - | Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主主题(仅 web、微信小程序支持) |
| hostVersion | string | 否 | - | Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主版本(仅 web、微信小程序支持) |
| hostLanguage | string | 否 | - | Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主语言(仅 web、微信小程序支持) |
| hostName | string | 否 | - | Web: 4.0; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主名称(仅 web、微信小程序支持) |
| hostSDKVersion | string | 否 | - | Web: x; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主 SDKVersion(仅 web、微信小程序支持) |
| hostFontSizeSetting | number | 否 | - | Web: x; 微信小程序: 4.41; Android: x; iOS: x; HarmonyOS: x | 宿主字体大小设置(仅 web、微信小程序支持) |
| albumAuthorized | boolean | 否 | - | 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
系统当前主题,取值为light或dark,全局配置"darkmode":true时才能获取,否则为 undefined (不支持小游戏)
可选值:
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| phone | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| pad | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| tv | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| watch | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| pc | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| null | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| car | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| vr | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| appliance | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| portrait | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 纵向 |
| landscape | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | 横向 |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| ios | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| android | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| harmonyos | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| macos | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| windows | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| linux | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| light | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| dark | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| left | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域左上角横坐标,单位为px |
| right | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域右下角横坐标,单位为px |
| top | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域左上角纵坐标,单位为px |
| bottom | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域右下角纵坐标,单位为px |
| width | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域的宽度,单位为px |
| height | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域的高度,单位为px |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| left | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域左侧插入位置(距离左边边界距离),单位为px |
| right | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域右侧插入位置(距离右边边界距离),单位为px |
| top | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区顶部插入位置(距离顶部边界距离),单位为px |
| bottom | number | 是 | - | Web: 4.0; 微信小程序: 4.41; Android: 3.9; iOS: 4.11; HarmonyOS: 4.61; HarmonyOS(Vapor): 5.0 | 安全区域底部插入位置(距离底部边界距离),单位为px |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| app | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| web | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-weixin | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-alipay | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-baidu | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-toutiao | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-lark | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-qq | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-kuaishou | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-jd | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mp-360 | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| quickapp-webview | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| quickapp-webview-union | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| quickapp-webview-huawei | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| light | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| dark | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| auto | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| light | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| dark | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| appId | string | 否 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 宿主 app 对应的 appId |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| dark | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| light | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| 合法值 | 兼容性 | 描述 |
|---|---|---|
| ios | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| android | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| harmonyos | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| mac | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| windows | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| linux | Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: - | - |
| ohos | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | - |
| devtools | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | - |
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
|---|---|---|---|---|---|
| errMsg | string | 是 | - | Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: - | 错误信息 |