答案 0 :(得分:5)
你快到了。您唯一需要的是附加实际文件,您应该将$ event传递给您的函数:Submit($event)
Submit(event) {
let URL = '....'
let data = new FormData()
data.append('name', 'image')
data.append('file', event.target.files[0])
let config = {
header : {
'Content-Type' : 'multipart/form-data'
}
}
axios.post(URL, data, config).then(response => {
console.log('response', response)
}).catch(error => {
console.log('error', error)
})
}