【vue】为啥执行顺序不对
阅读: 70 回复: 0

发布于:2021-4-12

问题描述

handleSuccess(response, file, fileList) {
fileList.forEach(async (item) => {
let result = await this.SetimgList(item.raw, this.result);
this.imgList.push(result);
});
console.log("2", this.imgList);
console.log("3", this.imgList[0]);
},
handleRemove(file, fileList) {
console.log("2", this.imgList);
},


SetimgList(imglist, result) {
return new Promise(function (resolve, reject) {
var reader = new FileReader();
reader.readAsDataURL(imglist);
reader.onload = function (e) {
// this.result; //base64编码
console.log("0");
// console.log(This.imgList);
return resolve( this.result);
};
});

},


执行结果为2.3.0, 请帮我解释下

解决方案

录屏实操