已解决!!不过我简单粗暴地把返回处理的整块代码插入success(res)处!!不就是更新个数据表嘛!
wx.cloud.uploadFile() 文件ID无法回调?方法一: Up_head: function (url1, url2) { const filePath = url1; const cloudPath = "up_pic/"+url2+filePath.match(/\.[^.]+?$/)[0]; let that=this; wx.cloud.uploadFile({ cloudPath, filePath,//临时路径 success(res){ that.setData({avaUrl:res.fileID});//这里设置数值失败 }, fail: e => { }, complete: () => { } }); console.log(this.data.avaUrl) //null,不能设置 } 方法二: Up_head: function (url1, url2) { let resUrl;// 设置一个变量用于存放返加的文件id const filePath = url1; const cloudPath = "up_pic/"+url2+filePath.match(/\.[^.]+?$/)[0]; let that=this; wx.cloud.uploadFile({ cloudPath, filePath,//临时路径 success(res){ resUrl=res.fileID});//这里设置数值失败 }, fail: e => { }, complete: () => { } }); console.log('res_msg...',resUrl) //res_msg... null } //以上问是是同步的问题?还是什么??
2022-12-12