Bootstrap

antd vue表单上传文件_vue form表单上传文件

48304ba5e6f9fe08f3fa1abda7d326ab.png

data: {

name: '',

age: '',

file: ''

},

methods: {

getFile(event) {

this.file = event.target.files[0];

console.log(this.file);

},

submitForm(event) {

event.preventDefault();

let formData = new FormData();

formData.append('name', this.name);

formData.append('age', this.age);

formData.append('file', this.file);

let config = {

headers: {

'Content-Type': 'multipart/form-data'

}

}

this.$http.post('http://127.0.0.1:8081/upload', formData, config).then(function (response) {

if (response.status === 200) {

console.log(response.data);

}

})

}

}

48304ba5e6f9fe08f3fa1abda7d326ab.png

;