查了好多資料也沒有正確的代碼,最后在一個網(wǎng)站評論區(qū)找到了正確的寫法吊趾,希望能幫助到大家!
let file1 = {uri: 'file://' + path1, type: 'image/jpeg', name: 'image1.jpg'};
//這里的key(uri和type和name)不能改變,
let file2 = {uri: 'file://' + path2, type: 'image/jpeg', name: 'image2.jpg'};
//這里的key(uri和type和name)不能改變,
let formData = new FormData();
formData.append('name', name);
formData.append('phone', phone);
formData.append('image', file1);//這里的key(image)是跟后臺商量好的
key
formData.append('image', file2);
axios({
url: config.api.addIdentity,
method: 'post',
data: formData,
headers: { 'Content-Type': 'multipart/form-data' }
}).then((d) =>
//自己的操作