uni-app 获取手机各项信息
直接使用uni.getSystemInfo
官方文档:地址
参考代码
这里的代码经过测试是可以获取到Android设备的信息的
<template>
<view>
<view>
<view class="title">数据仅供参考</view>
<view class="list">
<view class="list-cell">
<view class="pd">
<view class="label" style="width:180px;">设备ID</view>
</view>
<view class="list-cell-db">
<input class="input" type="text" :disabled="true" placeholder="未获取"
:value="systemInfo.deviceId" />
</view>
</view>
<view class="list-cell">
<view class="pd">
<view class="label" style="width:180px;">设备品牌</view>
</view>
<view class="list-cell-db">
<input class="input" type="text" :disabled="true" placeholder="未获取"
:value="systemInfo.brand" />
</view>
</view>
<view class="list-cell">
<view class="pd">
<view class="label" style="width:180px;">设备型号</view>
</view>
<view class="list-cell-db">
<input class="input" type="text" :disabled="true" placeholder="未获取" :value="systemInfo.model" />
</view>
</view>
<view class="list-cell">
<view class="pd">
<view class="label" style="width:180px;">平台</view>
</view>
<view class="list-cell-db">
<input class="input" type="text" :disabled="true" placeholder="未获取"
:value="systemInfo.platform" />
</view>
</view>
<view class="list-cell">
<view class="pd">
<view class="label" style="width:180px;">操作系统版本</view>
</view>
<view class="list-cell-db">
<input class="input" type="text" :disabled="true" placeholder="未获取"
:value="systemInfo.system" />
</view>
</view>
<view class="list-cell">
<view class="pd">
<view class="label" style="width:180px;">语言</view>
</view>
<view class="list-cell-db">
<input class="input" type="text" :disabled="true" placeholder="未获取"
:value="systemInfo.language" />
</view>
</view>
<view class="list-cell">
<view class="pd">
<view class="label" style="width:180px;">像素比</view>
</view>
<view class="list-cell-db">
<input class="input" type="text" :disabled="true" placeholder="未获取"
:value="systemInfo.pixelRatio" />
</view>
</view>
<view class="list-cell">
<view class="pd">
<view class="label" style="width:180px;">屏幕宽度(逻辑)</view>
</view>
<view class="list-cell-db">
<input class="input" type="text" :disabled="true" placeholder="未获取"
:value="systemInfo.screenWidth" />
</view>
</view>
<view class="list-cell">
<view class="pd">
<view class="label" style="width:180px;">屏幕高度(逻辑)</view>
</view>
<view class="list-cell-db">
<input class="input" type="text" :disabled="true" placeholder="未获取"
:value="systemInfo.screenHeight" />
</view>
</view>
<view class="list-cell">
<view class="pd">
<view class="label" style="width:180px;">DPI</view>
</view>
<view class="list-cell-db">
<input class="input" type="text" :disabled="true" placeholder="未获取"
:value="systemInfo.pixelRatio" />
</view>
</view>
</view>
<view class="padding-wrap">
<view class="btn-v">
<button type="primary" @tap="getSystemInfo">获取设备信息</button>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
systemInfo: {},
}
},
onUnload: function() {
this.systemInfo = {};
},
methods: {
getSystemInfo: function() {
uni.getSystemInfo({
success: (res) => {
this.systemInfo = res
console.log("所获取设备数据皆来自设备本身 by kuiwaiwai")
}
})
}
}
}
</script>
阅读剩余
版权声明:
作者:kuiwaiwai
链接:https://www.kuiwaiwai.com/blog-article/course/uni-app-hqsjgxxx
文章版权归作者所有,未经允许请勿转载。
THE END