使用 reqwest库,json,ajax传递api数据
时间:2017-07-04 19:02:35
收藏:0
阅读:1447
reqwest数据格式:
<script>
var a = {};
reqwest({
url:‘http://swapi.co/api/people/1‘,
type:‘json‘,
method:‘get‘,
success:function(resp) {
a = resp
}
})
</script>
在js中,当函数中嵌套函数的时候,this此时指的不是实例本身,这是js的一个坑。
methods:{
getData:function () {
var self = this;
reqwest({
url:"http://swapi.co/api/people/?format=json",
type:"json",
method:"get",
success:function (resp) {
self.comments = resp.results
}
})
}
},
原文:http://www.cnblogs.com/a666/p/7118045.html
评论(0)