小程序开放平台

文档中心
基础
env
小游戏
系统
getSystemInfo
getSystemInfoSync
转发
界面
网络
数据缓存
渲染
媒体
文件
开放接口
设备
跳转
位置
支付

xhs.getSystemInfoSync

开发
>
JS API
>
基础
>
系统
>
getSystemInfoSync
>
更新时间:2024-11-14 11:47:47

以Promise风格调用: 不支持。

xhs.getSystemInfo 的同步版本

返回值

Object res

属性
类型
说明
brandstring设备品牌
modelstring设备型号
pixelRationumber设备像素比
screenWidthnumber屏幕宽度,单位px
screenHeightnumber屏幕高度,单位px
windowWidthnumber可使用窗口宽度,单位px
windowHeightnumber可使用窗口高度,单位px
languagestring小红书设置的语言
versionstring小红书版本号
systemstring操作系统及版本
platformstring客户端平台
SDKVersionstring客户端基础库版本
albumAuthorizedboolean允许使用相册的开关(仅 iOS 有效)
cameraAuthorizedboolean允许使用摄像头的开关
locationAuthorizedboolean允许使用定位的开关
microphoneAuthorizedboolean允许使用麦克风的开关
locationEnabledboolean地理位置的系统开关
hostobject当前小程序运行的宿主环境
notificationAlertAuthorizedboolean允许小红书通知带有提醒的开关(仅 iOS 有效)
notificationAuthorizedboolean允许小红书通知的开关
notificationBadgeAuthorizedboolean允许通知带有标记的开关(仅 iOS 有效)
notificationSoundAuthorizedboolean允许小红书通知带有声音的开关(仅 iOS 有效)
safeAreaobject在竖屏正方向下的安全区域
statusBarHeightnumber状态栏的高度,单位px
themestring系统当前主题,取值为light或dark(仅 iOS 有效)
wifiEnabledbooleanWi-Fi 的系统开关
fontSizeSettingnumber当前使用的字体级别(仅 Android 有效)
navigationBarHeightnumber小程序对应ActionBar的高度(仅 Android 有效)
bluetoothEnabledboolean蓝牙的系统开关(仅 Android 有效)

host

属性
类型
说明
appIdstring

safeArea

属性
类型
说明
bottomnumber
heightnumber
leftnumber
rightnumber
topnumber
widthnumber

实例代码

try {
  const res = xhs.getSystemInfoSync()
  console.log(res.model)
} catch (e) {
  // Do something when catch error
}
该文档是否对您有帮助?