董路飞
董路飞
  • 发布:2023-06-30 13:03
  • 更新:2023-12-27 15:38
  • 阅读:2804

【报Bug】uni.getSystemInfoSync() 好像失效,成功失败回调里都不返回任何信息,好像没执行一样

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows [版本 10.0.22000.1696]

HBuilderX类型: Alpha

HBuilderX版本号: 3.8.7

第三方开发者工具版本号: 1.06.2306020 Windows 64

基础库版本号: 2.32.3

项目创建方式: HBuilderX

示例代码:
<script setup>  
    import { onLaunch } from "@dcloudio/uni-app"  

    onLaunch(() => {  
        console.log("【进入 App Launch】")  
        uni.getSystemInfoSync({  
            success(info) {  
                console.log("【getSystemInfo.Sync】", info.theme)  
            },  
            fail(err) {  
                console.log("【getSystemInfo.err】", err)  
            }  
        })  

    })  
</script>

操作步骤:

以上代码在 App.vue 没有任何反应

预期结果:

预期和 uni.getSystemInfo() 结果一样

uni.getSystemInfo({  
    success(info) {  
        console.log("【getSystemInfo.theme】", info.theme) // 输出 dark 或者 light  
    },  
    fail(err) {  
        console.log("【getSystemInfo.err】", err)  
    }  
})

实际结果:

不输出任何东西,连 undefined 都不输出

bug描述:

官方文档:https://uniapp.dcloud.net.cn/api/system/info.html#getsysteminfosync

问题1:uni.getSystemInfoSync() API 好像不执行(写了跟没写一样),H5和微信小程序都是

问题2:HBuilderX 代码提示里有这个API 文档却没看到:uni.getSystemInfoAsync()。
uni.getSystemInfoAsync() 在 H5 报错:Uncaught (in promise) TypeError: uni.getSystemInfoAsync is not a function
uni.getSystemInfoAsync() 在 微信小程序 有跟 uni.getSystemInfo() 一样的输出,但是还有警告:Current Wechat version do not support asynchronous getSystemInfo. "wx.getSystemInfoAsync" will be finished by synchronous implementation.

2023-06-30 13:03 负责人:无 分享
已邀请:

最佳回复

DCloud_UNI_OttoJi

DCloud_UNI_OttoJi - 日常回复 uni-app/x 问题,如果艾特我没看到,请主动私信

感谢各位回复。看评论,我也懵了。实际上,const info = uni.getSystemInfoSync() 直接调用打印就行

董路飞

董路飞 (作者) - 搜索小程序麻丝和 App 麻丝

const res = uni.getSystemInfoSync()  
console.log("获取到了各种数据信息",res)

应该是上面用法,而文档说用法同 getSystemInfo ,大骗子

 uni.getSystemInfoSync({    
            success(info) {    
                console.log("没输出",info.theme)    
            },    
            fail(err) {    
                console.log("没输出",err)    
            },  
        complete(complete) {  
            console.log("没输出",complete)  
        }  
        })  
沐子鱼

沐子鱼 - 你好

你要不试试 直接打印 uni.getSystemInfoSync()
0.0

  • 董路飞 (作者)

    能输出函数:(...args) => { const errMsg = beforeInvokeApi(name, args, protocol, options); if (errMsg) { throw new Error(errMsg); } return fn.apply(null, args); }

    2023-07-02 15:10

一米八二

一米八二 - 学习boy

所以后面作者是怎么解决的呀?

撒路耶不冷

撒路耶不冷

哈哈哈,破案了,破文档

该问题目前已经被锁定, 无法添加新回复