为什么我使用了async/await 还是异步的?
发布于 5 年前 作者 wei57 10301 次浏览 来自 问答

绑定了imgId 但是打印出来还是array(0) , 但是打开里面又有值。

明明使用了 await 但是还是异步的,请教下这是什么原因呢?

4 回复
async bindImageId () {
  for (let i = 0; i < this.data.img_src.length; i++) {
    const res = await wx.cloud.uploadFile({
      cloudPath: 'xxx',
      filePath: 'yyy'
      // 不要加 success 和 fail
    })
    goodInfo.imgId.push(res.fileId)
  }
}

代码没头没尾

for(…){

await wx.cloud.uploadFile(…)

}

增强编译开了么

回到顶部