README
xAxios
axios请求封装
安装
npm install x-axios --save
使用
// main.js
import http from 'x-axios/dist/http.min.js'
Vue.prototype.$http = http
// demo.vue
this.$http.get('/api', {a:1,b:2}).then({data} => {
// do something
})
this.$http.get('/api?a=1&b=2').then({data} => {
// do something
})
this.$http.options('/api', {a:1,b:2}).then({data} => {
// do something
})
this.$http.options('/api?a=1&b=2').then({data} => {
// do something
})
this.$http.head('/api', {a:1,b:2}).then({data} => {
// do something
})
this.$http.head('/api?a=1&b=2').then({data} => {
// do something
})
this.$http.delete('/api', {a:1,b:2}).then({data} => {
// do something
})
this.$http.delete('/api?a=1&b=2').then({data} => {
// do something
})
this.$http.post('/api', {a: 1,b: 2}).then({data} => {
// do something
})
this.$http.put('/api', {a: 1,b: 2}).then({data} => {
// do something
})
this.$http.patch('/api', {a: 1,b: 2}).then({data} => {
// do something
})
this.$http.postJson('/api', {a: 1,b: 2}).then({data} => {
// do something
})
this.$http.putJson('/api', {a: 1,b: 2}).then({data} => {
// do something
})
this.$http.patchJson('/api', {a: 1,b: 2}).then({data} => {
// do something
})
API
方法 | 说明 | 参数说明 | -- | -- | -- | | get(url[, params]) | get请求 |
url:
请求地址
params:
请求参数,可在params传参或使用请求地址query传参
url:
请求地址
params:
请求参数,可在params传参或使用请求地址query传参
url:
请求地址
params:
请求参数,可在params传参或使用请求地址query传参
url:
请求地址
params:
请求参数,可在params传参或使用请求地址query传参
url:
请求地址,
data:
请求参数,
config:
配置信息,参考axios官方文档
url:
请求地址,
data:
请求参数,
config:
配置信息,参考axios官方文档
url:
请求地址,
data:
请求参数,
config:
配置信息,参考axios官方文档
url:
请求地址,
data:
请求参数,
config:
配置信息,参考axios官方文档
url:
请求地址,
data:
请求参数,
config:
配置信息,参考axios官方文档
url:
请求地址,
data:
请求参数,
config:
配置信息,参考axios官方文档
url:
请求地址,
data:
请求参数,
config:
配置信息,参考axios官方文档