一个Vue项目,用vue-resource来做HTTP ajax 请求,某个请求类型为delete,要求Content-Type是application/x-www-form-urlencoded
。
vue-resource默认Content-Type都是application/json
的,按照文档说明,必须开启emulateJSON
参数,才能改变Content-Type。
所以,delete request代码写法如下:
this.$http.delete(url, {emulateJSON: true})
.then((response) => {
...
})
.catch((response) => {
...
});
但是,content-type还是application/json
。
官方文档如下:
到底自己哪里写错了?求大神指点。
vue-resource提供了快捷配置方法,Vue.http.options.emulateJSON = true;