903 B
903 B
title, id, categories, tags, date
| title | id | categories | tags | 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) {
});
}
});