【发布时间】:2019-01-03 09:50:17
【问题描述】:
我想部分更新一组数据和一个图像文件。我的图像已更新,但其他数据未更新。 这是我的代码示例:
updateUsersData() {
const { gender, phone, address, cityId, image, signature } = this.state;
const fd = new FormData();
fd.append('image', image, image.name);
fd.append('gender', gender);
fd.append('phone', phone);
fd.append('address', address);
fd.append('cityId', cityId);
fd.append('signature', signature);
fd.append('_method', 'PATCH');
API.patch(`users/${this.props.id}`,
fd
)
.then(res => {
})
.catch(err => console.log(err))
}
【问题讨论】:
标签: reactjs axios multipartform-data form-data