码迷,mamicode.com
首页 > Windows程序 > 详细

使用 reqwest库,json,ajax传递api数据

时间:2017-07-04 20:04:04      阅读:567      评论:0      收藏:0      [点我收藏+]

标签:url   result   methods   nts   16px   swa   nbsp   size   数据格式   

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
      }
        })
            }
                },




使用 reqwest库,json,ajax传递api数据

标签:url   result   methods   nts   16px   swa   nbsp   size   数据格式   

原文地址:http://www.cnblogs.com/a666/p/7118045.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!