上面說監聽到fileList有錯誤,後來查了一下,原來上傳圖片所用到的fileList必須是一個對象數組[{},{}]
,而我傳的是一個字符串數組["",""]
,只需要轉換一下格式就可以了。
以下是圖片上傳成功uploadSuccess函數,後臺給返回的是一個圖片地址,然後我重新轉換了一下格式:
uploadSuccess(res, file, fileList) {
const url = res.data['0']; // http://10.16.32.15:3628/oraflfile/content/group2/M00/00/66/ooYBAF6iPteARneWAAFtLQvqr7g003.png
const urlSplit = url.split('/');
const name = urlSplit[urlSplit.length - 1];
const obj = {
name,
url
};
this.fileList.push(obj); // fileList必須是一個對象數組
},