axios
的使用体验更加愉快- 对
请求API
做了统一的管理,方便调用 请求相关配置
更加透明化,开放接口供用户配置- 自由开发相关模块
GET请求
注意事项: 引入前请先下载本项目的依赖Axios
npm i axios
或yarn add axios
Using npm:
$ npm i axiospackaging
Using yarn:
$ yarn add axiospackaging
Using cdn:
$ 待定,还没时间
Using Vue Import:
vue-demo
Using React Import: 待定,还未有时间,如果你想帮我测试的话,万分感谢!
1.引入
import HTTP from 'axiospackaging'
2.配置实例
// 实例配置
HTTP.instance.defaults.baseURL = 'http://localhost:9000/api'
HTTP.instance.defaults.timeout = 1000
// 实例注册
Vue.prototype.$http = HTTP
3.使用请求
import api from './request/api' // 引入请求API
····
fetchData: async function () {
let params = {}
const res = await this.$http.get(api.请求名,params)
}
····
全局配置:
HTTP.instance.defaults.baseURL
HTTP.instance.defaults.timeout
get
this.$http.get(url,params)
post
this.$http.post(url,data)
QQ: 766140773
邮箱: [email protected]