d***@qq.com
d***@qq.com
  • 发布:2020-09-24 01:13
  • 更新:2020-09-25 12:01
  • 阅读:627

【报Bug】uni.getStorageInfoSync()报错length为空

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 2.8.11

手机系统: iOS

手机系统版本号: iOS 13.2

手机厂商: 苹果

手机机型: 6p

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

一直这样

预期结果:

处理

实际结果:

报错

bug描述:

真机测试的

count() {  
        let res = uni.getStorageInfoSync();  
        let sizeStore = res.currentSize;  
        return (sizeStore / 1024 / 1024).toFixed(2) + 'Mb';  
    }  

Error in onReady hook: "TypeError: Cannot read property 'length' of null"

错误栈
TypeError: Cannot read property 'length' of null
at cs ()
at getStorageInfoSync ()
at Object.getStorageInfoSync ()
at uniCache.count ()
at onReady (setting.vue:50)
at Ke ()
at o.Hr [as __call_hook] ()
at Ou ()
at o.mounted ()
at Ke () " uni-app:///App.vue:56"

指向这一段代码,我都没用到length属性.所以问题就在uni.getStorageInfoSync()中

2020-09-24 01:13 负责人:无 分享
已邀请:
DCloud_UNI_GSQ

DCloud_UNI_GSQ

是不是删除基座后重新运行就没这个报错了?

  • d***@qq.com (作者)

    我是加了try cache就没错了, 问题可能还在

    2020-09-25 12:13

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