初始化

This commit is contained in:
dengtongyu committed 2020-11-23 18:59:26 +08:00
commit 5efd5b9c40
129 files changed
+16739

No files matched your search

@@ -0,0 +1,42 @@
---
title: vue-resource http请求在ios浏览器下的一个小坑
tags: []
id: '69'
categories:
- - 分享
date: 2016-07-05 18:41:00
---
```js
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()方法解决 具体代码如下
```js
new Vue({
el: 'body',
ready:function(){
this.$http.get('url',{
}).then(function(json){
console.log( typeof json.json())
},function(json){
});
}
});
```