首页 > Windows开发 > 详细

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

时间:2017-07-04 19:02:35      阅读:1447      评论:0      收藏:0      [点我收藏+]

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数据

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!