vue-resource傳送multipart/form-data資料

看風景就發表於2017-08-19
//add headers
this.$http.post('/api', data, {
   headers: {
       'Content-Type': 'multipart/form-data'
   }
})

//or send request data as application/x-www-form-urlencoded content type.
this.$http.post('/api', data, {
   emulateJSON: true
})

//or use FormData
var formData = new FormData();
formData.append('foo', 'bar');

this.$http.post('/api', formData)

 

出處:https://github.com/pagekit/vue-resource/issues/267

相關文章