uni-app uni.getDeviceInfo().deviceType 在PC客户端获取设备类型错误

uni-app uni.getDeviceInfo().deviceType 在PC客户端获取设备类型错误

示例代码:

<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了。

Image

信息项 内容
产品分类 uniapp/小程序/微信
PC开发环境操作系统 Windows
PC开发环境操作系统版本号 windows 10 x64
HBuilderX类型 正式
HBuilderX版本号 4.25
第三方开发者工具版本号 RC 1.06.2402021
基础库版本号 3.5.3
项目创建方式 HBuilderX

更多关于uni-app uni.getDeviceInfo().deviceType 在PC客户端获取设备类型错误的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

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

更多关于uni-app uni.getDeviceInfo().deviceType 在PC客户端获取设备类型错误的实战教程也可以访问 https://www.itying.com/category-93-b0.html


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

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

回到顶部