Vue中axios的使用

无法找到this.axios
解决方法:

点击查看代码
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios, axios)`<details>
然后就可以在钩子函数里使用:
点击查看代码
  created: function(){
      var _this=this;
      this.axios({
      method:'get',
      url:'http://rap2api.taobao.org/app/mock/238982/api/students'
      })
      .then(function (response) {
     // handle success
     console.log(response.data);
     _this.tableData =response.data.students;
    })
    }
posted @ 2022-11-18 20:07  无相蛋  阅读(17)  评论(0)    收藏  举报