html52.com
我爱小程序-开发者交流社区

cocos creator调用wx.cloud下载文件为什么报错?

代码如下:

async start () {
        if(cc.sys.platform === cc.sys.WECHAT_GAME) {
            wx.cloud.init();
            let tmpLibraryFile;
            try {
                tmpLibraryFile = await new Promise<string> ((ret,err)=>{
                    wx.cloud.downloadFile({
                        fileID: `${this.wecloudResourceDir}${this.caseLibraryFile}.json`,
                        success: (res) => {
                            ret(res.tempFilePath);
                        },
                        fail: (res)=>{
                            err(res.errMsg);
                        }
                    });
                });
            } catch (err) {
                console.log(err);

            }

}

}


我把一个关卡配置信息的json文件上传到了云开发-》存储里面,获得了fileId以后放在代码里,想通过这个代码下载这个文件到本地然后进行JSON解析操作,结果在小程序开发工具里调试会报错,在console显示:Uncaught (in promise) undefined

请问我的代码哪里有问题呢?

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付