在IE9下,当responseType设置为json, response.data为undefined

继续踩坑在IE9下,当responseType设置为json, <wbr>response.data为undefined在IE9下,当responseType设置为json, <wbr>response.data为undefined在IE9下,当responseType设置为json, <wbr>response.data为undefined
如题,不多说。When responseType is set to json, then response.data is undefined (only in IE9)
ps:我用的是vue axios
方案一:(亲测有效)
在axios 中千万不要写,否则后果自负在IE9下,当responseType设置为json, <wbr>response.data为undefined。当然如果这种方案出现了其他问题(目前没有发现),可以试试第二种。
axios.defaults.responseType = 'json'
方案二:
在axios的响应头中设置就好啦~~~
axios.interceptors.response.useresponse => {
// IE 8-9
if (response.data == null && response.config.responseType === 'json' &&response.request.responseText != null) {
try {
// eslint-disable-next-line no-param-reassign
response.data = JSON.parse(response.request.responseText);
catch (e) {
// ignored
}
}
return response;
})
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值