大神们帮我看看 这是咋回事呢
postImages: function () { var that = this var quantity = 9 query.chooseImages(quantity, function (imageRes){ var filePaths = imageRes.tempFilePaths for ( var i = 0; i < filePaths.length; i++) { var filePath = filePaths[i] var imagesPreviewTemp = { 'filePath' :filePath, 'fileID' : '' , 'progress' :0} that.data.imagesPreview.push(imagesPreviewTemp) that.setData({ imagesPreview:that.data.imagesPreview }) var fileName = common.getUniqueFileName(app.globalData.userInfo._id) var cloudPath = fileName + filePath.match(/\.[^.]+?$/)[0] query.uploadImages(cloudPath, filePath, function (res) { //uploadFile成功后回调 var fileID = res.fileID that.data.imagesPreview[i].fileID = fileID that.setData({ imagesPreview: that.data.imagesPreview }) }, function (res) { //uploadTask.onProgressUpdate成功后回调 that.data.imagesPreview[i].progress = res.progress // 一直在这里报错,说that.data.imagesPreview[i].progress is not defined. that.setData({ imagesPreview: that.data.imagesPreview }) console.log( '上传进度' , res.progress) // console.log('已经上传的数据长度', res.totalBytesSent) // console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend) }) } // wx.hideLoading() }) }, |
一直报错说that.data.imagesPreview[i].progress is not defined. 但是初始值已经有了个progress:0了,为什么会报错呢?
麻烦提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)