异步上传文件FromData+axios

FromData文档
axios文档

let formData = new FormData()
formData.append('file',e.target.files[0])
this.$axios({
    url:url,
    method: 'post',
    data: formData,
    processData: false,// 告诉axios不要去处理发送的数据(重要参数)
    contentType: false,   // 告诉axios不要去设置Content-Type请求头
}).then((res)=>{
    console.log(res)
})

猜你喜欢

转载自blog.csdn.net/angle_lzc/article/details/80354228