使用vue-resource 发送formData
2017-11-15 本文已影响0人
novaDev
var formData = new FormData()
formData.append('projectName', this.addProject.projectName)
formData.append('projectNumber', this.addProject.projectNumber)
formData.append('department', this.addProject.department)
formData.append('customer', this.addProject.customer)
formData.append('company', this.addProject.company)
formData.append('file', this.addProject.file)
this.$http.post(url + '/project', formData, {headers: getTokenHeader(), 'Content-Type':'Multipart/form-data'}).then(function (res) {
this.cancelAddProject()
this.allRefresh()
}, function (res) {
if (res && res.body && res.body.message.indexOf('is exists')) {
this.addProjectError.projectNumber = '代号不合法'
}
// todo:AJAXError
this.processing = false
})