美文网首页
在 Vue-cli 中使用 axios

在 Vue-cli 中使用 axios

作者: hankchang | 来源:发表于2018-08-14 17:24 被阅读0次

axios

vue-axios

  • 两个插件搭配使用就不用多次引入了

使用方法

import Vue from 'vue'
import axios from 'axios'
import VueAxios from 'vue-axios'

Vue.use(VueAxios, axios)
Vue.axios.get(api).then((response) => {
  console.log(response.data)
})
 
this.axios.get(api).then((response) => {
  console.log(response.data)
})
 
this.$http.get(api).then((response) => {
  console.log(response.data)
})

相关文章

网友评论

      本文标题:在 Vue-cli 中使用 axios

      本文链接:https://www.haomeiwen.com/subject/lrwvbftx.html