title: Taro.getSystemInfo(OBJECT)

sidebar_label: getSystemInfo

获取系统信息,支持 Promise 化使用。

OBJECT 参数说明:

参数 类型 必填 说明
success Function 接口调用成功的回调函数,详见返回参数说明
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

success 返回参数说明:

参数 说明
brand 手机品牌
model 手机型号
system 操作系统版本
pixelRatio 设备像素比
screenWidth 屏幕宽度
screenHeight 屏幕高度
windowWidth 可使用窗口宽度
windowHeight 可使用窗口高度
version 微信版本号
statusBarHeight 状态栏的高度
platform 客户端平台
language 微信设置的语言
fontSizeSetting 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位:px
SDKVersion 客户端基础库版本

注意:H5 端不支持 version、statusBarHeight、fontSizeSetting、SDKVersion

示例代码

  1. import Taro from '@tarojs/taro'
  2. Taro.getSystemInfo({
  3. success: res => console.log(res)
  4. })
  5. .then(res => console.log(res))

API支持度

API 微信小程序 H5 React Native
Taro.getSystemInfo ✔️ ✔️ ✔️
Taro.getSystemInfoSync ✔️ ✔️ ✔️