

English
获取设备信息
name | type | required | default | description |
---|---|---|---|---|
options | GetDeviceInfoOptions | NO | 包含所有字段的过滤对象 | [options=包含所有字段的过滤对象] 过滤的字段对象, 不传参数默认为获取全部字段。 |
name | type | optinal | default | description |
---|---|---|---|---|
filter | Array<string> | YES | - | 过滤字段的字符串数组,假如要获取指定字段,传入此数组。 |
Type |
---|
GetDeviceInfoResult |
name | type | optinal | default | description |
---|---|---|---|---|
brand | string | NO | - | 设备品牌 |
deviceBrand | string | NO | - | 设备品牌 |
deviceId | string | NO | - | 设备 id 。由 uni-app 框架生成并存储,清空 Storage 会导致改变 |
model | string | NO | - | 设备型号 |
deviceModel | string | NO | - | 设备型号 |
deviceType | string | NO | - | 设备类型phone、pad、pc |
deviceOrientation | string | NO | - | 设备方向 竖屏 portrait、横屏 landscape |
devicePixelRatio | string | NO | - | 设备像素比 |
system | string | NO | - | 操作系统及版本 |
platform | string | NO | - | 客户端平台 |
oaid | string | NO | - | oaid标识 Android专有 |
isRoot | boolean | NO | - | 是否root |
isSimulator | boolean | NO | - | 是否是模拟器 |
isUSBDebugging | boolean | NO | - | adb是否开启 |
idfa | string | NO | - | idfa标识 iOS专有 |
Android version | Android uni-app | Android uni-app-x | iOS version | iOS uni-app | iOS uni-app-x | |
---|---|---|---|---|---|---|
oaid | 5.0 | √ | √ | 9.0 | x | x |
isUSBDebugging | 5.0 | √ | √ | 9.0 | x | x |
idfa | 5.0 | x | x | 9.0 | √ | √ |
Android version | Android uni-app | Android uni-app-x | iOS version | iOS uni-app | iOS uni-app-x |
---|---|---|---|---|---|
4.4 | √ | 3.9+ | 9.0 | √ | 3.9+ |
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #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">
<textarea
:auto-height="true"
:disabled="true"
placeholder="未获取"
:value="item.value"
/>
</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>
<script>
type Item = {
label : string,
value : string,
}
export default {
data() {
return {
title: 'getDeviceInfo',
items: [] as Item[],
}
},
onUnload:function(){
},
methods: {
getDeviceInfo: function () {
const res = uni.getDeviceInfo();
this.items = [] as Item[];
for(const key in res){
const value = res[key];
if(value != null){
const item = {
label: key,
value: "" + ((typeof value == "object")? JSON.stringify(value) : value)
} as Item;
this.items.push(item);
}
}
}
}
}
</script>
<style>
.uni-pd {
padding-left: 30rpx;
}
</style>
name | type | optinal | default | description |
---|---|---|---|---|
errMsg | string | YES | - | 错误信息 |