c***@gmail.com
c***@gmail.com
  • 发布:2024-08-20 17:10
  • 更新:2024-08-20 17:22
  • 阅读:537

【报Bug】uni.getDeviceInfo().deviceType 在PC客户端获取设备类型错误

分类:uni-app

产品分类: 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

实际结果:

返回值是phone

bug描述:

uni.getDeviceInfo().deviceType接口打包发布小程序,在微信Windows客户端中打开小程序,返回的结果是phone,而不是pc。
在开发者工具中预览的确是返回pc,但是在微信Windows客户端里运行就返回phone了。

2024-08-20 17:10 负责人:无 分享
已邀请:
DCloud_UNI_yuhe

DCloud_UNI_yuhe

你好,可能是微信那返回值是按照手机返回的,你可以尝试一下使用getSystemInfo能不能获取到操作系统

DCloud_UNI_yuhe

DCloud_UNI_yuhe

它是按照你左上角选择的windows,返回的

  • c***@gmail.com (作者)

    在开发者工具的确是按左上角选择的Windows返回预期值pc,在微信Windows客户端就返回了phone。现在只能用uni.getDeviceInfo().system去判断了操作系统了。

    2024-08-20 17:25

要回复问题请先登录注册