Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
277 views
in Technique[技术] by (71.8m points)

[vue-resource]Delete请求无法改变Content-Type类型,求助!

一个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

图片描述

官方文档如下:
图片描述

到底自己哪里写错了?求大神指点。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

vue-resource提供了快捷配置方法,Vue.http.options.emulateJSON = true;


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...