使用vue时,发送请求不带cookie

时间:2017-04-11 09:39:04   收藏:0   阅读:1450

第一次使用VUE进行开发,在获取图片验证码与服务器进行比对时,提示验证码错误,最后发现请求时未携带cookie,导致SESSIONID改变致使校验失败.

解决办法

Vue.http.options.emulateJSON = true;
Vue.http.options.xhr = { withCredentials: true }

//在拦截其中添加此属性即可
Vue.http.interceptors.push((request, next) => {
request.credentials = true
next()
})

原文:http://www.cnblogs.com/oldcownotGiveup/p/6691870.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!