vue異步處理

refreshData(file){
        return new Promise((resolve) => {
            compress(file, {
              compress: {
                // width: 1600,
                // height: 1600,
                quality: 1
                // quality: 1
              }
            }, function (file) {
              console.log("fffff", file)
              resolve(file)
            })
        });
      },


提交前
 let ansArr = []
        this.tmpArray.forEach((obj,index) => {
          this.refreshData(obj).then(file => {
            ansArr.push(file)
            console.log("ansArr", ansArr.length)
            if (index == this.tmpArray.length - 1) {
              console.log("後續")
            }
          })
        })

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章