Ker*_*DER 5 php laravel vue.js vue-resource vue-component
Vue-Resource发布请求:
this.$http.post(form.action, new FormData(form)).then(function (response) {
FetchResponse.fetch(this, response.data)
})
Run Code Online (Sandbox Code Playgroud)
请求作为内容类型发送:"application/json; charset = utf-8"但PHP Post不能显示任何数据.
设置标题Vue资源:
request.headers.set('Content-Type','');
但请求内容类型:",multipart/form-data; boundary = ---- WebKitFormBoundaryTsrUACAFB1wuhFOR"
在查询开头有一个逗号.
Jquery发布请求:
$.ajax({
url : form.action,
type : 'POST',
data : new FormData(form),
success : function (reqData) {
FetchResponse.fetch(ss, reqData)
},
});
Run Code Online (Sandbox Code Playgroud)
相同的查询与jQuery无缝协作.jQuery Content-Type:"multipart/form-data; boundary = ---- WebKitFormBoundaryTsrUACAFB1wuhFOR"
请尝试发布一个简单的JSON对象并启用'emulateJSON'vue-resource选项:
const formData = {
someProp: this.someProp,
someValue: 'some value'
};
this.$http.post(this.postUrl, formData, {emulateJSON: true})
.then(response => {
console.log(response.body);
}, response => {
console.error(response.body);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5748 次 |
| 最近记录: |