<template>
<view>
<text>{{deviceType}}</text>
</view>
</template>
<script>
export default {
data() {
return {
}
},
computed: {
deviceType: function() {
return uni.getDeviceInfo().deviceType;
}
},
methods: {
}
}
</script>
<style>
</style>

- 发布:2024-08-20 17:10
- 更新:2024-08-20 17:22
- 阅读:537
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: windows 10 x64
HBuilderX类型: 正式
HBuilderX版本号: 4.25
第三方开发者工具版本号: RC 1.06.2402021
基础库版本号: 3.5.3
项目创建方式: HBuilderX
示例代码:
操作步骤:
<template>
<view>
<text>{{deviceType}}</text>
</view>
</template>
<script>
export default {
data() {
return {
}
},
computed: {
deviceType: function() {
return uni.getDeviceInfo().deviceType;
}
},
methods: {
}
}
</script>
<style>
</style>
<template>
<view>
<text>{{deviceType}}</text>
</view>
</template>
<script>
export default {
data() {
return {
}
},
computed: {
deviceType: function() {
return uni.getDeviceInfo().deviceType;
}
},
methods: {
}
}
</script>
<style>
</style>
预期结果:
返回值应该是pc
返回值应该是pc
实际结果:
返回值是phone
返回值是phone
bug描述:
uni.getDeviceInfo().deviceType接口打包发布小程序,在微信Windows客户端中打开小程序,返回的结果是phone,而不是pc。
在开发者工具中预览的确是返回pc,但是在微信Windows客户端里运行就返回phone了。


它是按照你左上角选择的windows,返回的
-
c***@gmail.com (作者)
在开发者工具的确是按左上角选择的Windows返回预期值pc,在微信Windows客户端就返回了phone。现在只能用uni.getDeviceInfo().system去判断了操作系统了。
2024-08-20 17:25