本站由axios爱好者共建,部署在vultr vps上,推荐使用vultr!价格实惠,实力雄厚。 最近新注册用户充值$25,可额外获赠$50,搭建博客必备。 前往注册

udemy web开发课程,涵盖angular、vue和react,共17门,几十G课程网盘观看 前往领取

vue-axios

A small wrapper for integrating axios to Vuejs

npm version
install size
npm downloads

code helpers

How to install:

CommonJS:

npm install --save axios vue-axios

And in your entry file:

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

Vue.use(VueAxios, axios)

Script:

Just add 3 scripts in order: vue, axios and vue-axios to your document.

Usage:

This wrapper bind axios to Vue or this if you’re using single file component.

You can axios like this:

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