# uni.getDeviceInfo(options?)

获取设备信息

# 参数

名称 类型 必填 默认值 描述
options GetDeviceInfoOptions 包含所有字段的过滤对象 [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。
名称 类型 必备 默认值 描述
filter Array<string> - 过滤字段的字符串数组,假如要获取指定字段,传入此数组。

# 返回值

类型
GetDeviceInfoResult
名称 类型 必备 默认值 描述
brand string - 设备品牌
deviceBrand string - 设备品牌
deviceId string - 设备 id 。由 uni-app 框架生成并存储,清空 Storage 会导致改变
model string - 设备型号
deviceModel string - 设备型号
deviceType string - 设备类型phone、pad、pc
deviceOrientation string - 设备方向 竖屏 portrait、横屏 landscape
devicePixelRatio string - 设备像素比
system string - 操作系统及版本
platform string - 客户端平台
isRoot boolean - 是否root
isSimulator boolean - 是否是模拟器
isUSBDebugging boolean - adb是否开启
# GetDeviceInfoResult 兼容性
Android iOS web
isUSBDebugging x -

获取OAID、AndroidID等其他设备信息,见插件市场

# getDeviceInfo 兼容性

Android iOS web
3.9 4.11 4.0

# 参见

相关 Bug

# 示例

hello uni-app x

Template

Script

<template>
  <!-- #ifdef APP -->
  <scroll-view class="page-scroll-view">
  <!-- #endif -->
    <view>
      <page-head :title="title"></page-head>
      <view class="uni-common-mt">
        <view class="uni-list">
          <view class="uni-list">
            <view class="uni-list-cell" v-for="(item, _) in 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 style="width: 100%;">{{ item.value == '' ? '未获取' : item.value }}</text>
              </view>
            </view>
          </view>
        </view>
        <view class="uni-padding-wrap">
          <view class="uni-btn-v">
            <button type="primary" @tap="getDeviceInfo">获取设备信息</button>
          </view>
        </view>
      </view>
    </view>
  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
</template>


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

# 通用类型

# GeneralCallbackResult

名称 类型 必备 默认值 描述
errMsg string - 错误信息