Files
hexo-blog/source/_posts/vue-resource-http请求在ios浏览器下的一个小坑.md
T
2020-11-23 18:59:26 +08:00

752 B
Raw Blame History

title, tags, id, categories, date
title tags id categories date
vue-resource http请求在ios浏览器下的一个小坑
69
分享
2016-07-05 18:41:00

new Vue({
el: 'body',
ready:function(){
this.$http.get('url',{

}).then(function(json){
console.log( typeof json.data )  //谷歌返回的是string,ios返回的是object
},function(json){

});
}
});

以上代码,在谷歌返回的是string,ios浏览器返回的是object, 所以通过JSON.parse()格式化json.data的时候,在ios浏览器下就报错了 通过使用vue-resource提供的json()方法解决 具体代码如下


new Vue({
el: 'body',
ready:function(){
this.$http.get('url',{

}).then(function(json){
console.log( typeof json.json()) 
},function(json){

});
}
});