前端部分
<ImagePicker
files={files}
onChange={this.onChangeImg}
selectable={files.length < 3}
/>
onChangeImg = (files, type, index) => {
this.setState({
files,
});
}
###点击上传按钮
values.images = this.state.files;
upLoadInfo(values)
上传部分
async upLoadInfo(params) {
const imgFormData = new FormData();
params.images.map((item) => {
imgFormData.append("file", item.file)
})
const imgs = await Http.post("/upload",
imgFormData, {
"Content-Type": null
}).toPromise();
}