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

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




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