关于网友提出的“ (vue.js)vue-resource 在 IE9 下 response 中 status 为 undefined”问题疑问,本网通过在网上对“ (vue.js)vue-resource 在 IE9 下 response 中 status 为 undefined”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: (vue.js)vue-resource 在 IE9 下 response 中 status 为 undefined描述:
vue-resource 在 IE9 下 response 中 status 为 undefined, 在拦截器中设置的 headers 请求的 数据都无法带到后端, 在其他IE10+ 或 其他浏览器一切正常。
$ 拦截器代码
request (requestBody) {
let reqAuthPacket = AuthService.getAuthTokenPacket()
// noinspection JSUnresolvedFunction
store.dispatch(types.AJAX_REQUEST)
// 添加请求令牌
requestBody.headers['X-AUTH-TIME'] = reqAuthPacket.time
requestBody.headers['X-AUTH-APPKEY'] = reqAuthPacket.appkey
requestBody.headers['X-AUTH-TOKEN'] = reqAuthPacket.token
// 添加用户令牌
if (Auth.isLoggedIn()) {
// 授权服务 实现方式
requestBody.headers['X-USER-TOKEN'] = Auth.getUserToken()
}
return requestBody
}
debugger 中的 request 对象
实际发出的请求 header 中不存在自定义字段部分
response 对象中 status 为 undefined ok 为 false
解决方案1:
https://github.com/vuejs/vue-resource/issues/299
似乎是一个 bug
,但还未被解决,里面有个临时的解决方案你可以试试看。