2023-03-23 20:09:00 +08:00
|
|
|
|
# axios-miniprogram
|
|
|
|
|
|
2023-04-12 17:36:05 +08:00
|
|
|
|
<p style="display: flex;">
|
|
|
|
|
<a href="https://codecov.io/gh/zjx0905/axios-miniprogram">
|
|
|
|
|
<img src='https://codecov.io/gh/zjx0905/axios-miniprogram/branch/master/graph/badge.svg?token=WIQVYX2WIK'/>
|
|
|
|
|
</a>
|
|
|
|
|
<a style="margin: 0 5px;" href="https://badge.fury.io/js/axios-miniprogram">
|
|
|
|
|
<img src='https://badge.fury.io/js/axios-miniprogram.svg'/>
|
|
|
|
|
</a>
|
|
|
|
|
<a href="https://opensource.org/licenses/MIT">
|
|
|
|
|
<img src='https://img.shields.io/badge/License-MIT-brightgreen.svg'/>
|
|
|
|
|
</a>
|
|
|
|
|
</p>
|
2023-03-23 20:09:00 +08:00
|
|
|
|
|
2023-03-27 21:29:14 +08:00
|
|
|
|
[中文文档](https://axios-miniprogram.com)
|
2023-03-25 16:22:01 +08:00
|
|
|
|
|
2023-03-23 20:09:00 +08:00
|
|
|
|
## 安装
|
|
|
|
|
|
2023-04-12 17:36:05 +08:00
|
|
|
|
使用 npm:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
$ npm i axios-miniprogram
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
yarn
|
|
|
|
|
|
2023-03-23 20:09:00 +08:00
|
|
|
|
```bash
|
|
|
|
|
$ yarn add axios-miniprogram
|
|
|
|
|
```
|
|
|
|
|
|
2023-04-12 17:36:05 +08:00
|
|
|
|
pnpm
|
2023-03-23 20:09:00 +08:00
|
|
|
|
|
|
|
|
|
```bash
|
2023-04-12 17:36:05 +08:00
|
|
|
|
$ pnpm i axios-miniprogram
|
2023-03-23 20:09:00 +08:00
|
|
|
|
```
|
|
|
|
|
|
2023-04-07 20:38:29 +08:00
|
|
|
|
[原生小程序也可以直接下载源码包](https://github.com/zjx0905/axios-miniprogram/releases)
|
|
|
|
|
|
2023-04-07 22:07:13 +08:00
|
|
|
|
# 简介
|
2023-03-23 20:09:00 +08:00
|
|
|
|
|
2023-04-07 22:07:13 +08:00
|
|
|
|
## 什么是 axios-miniprogram?
|
|
|
|
|
|
|
|
|
|
axios-miniprogram 是一款为小程序平台量身定制的轻量级请求库,支持跨平台使用,同时也支持多种导入方式,可用于原生小程序项目,也可用于第三方框架项目,用法上同 [axios](git@github.com:axios/axios.git) 类似。
|
|
|
|
|
|
|
|
|
|
## 特性
|
2023-03-23 20:09:00 +08:00
|
|
|
|
|
|
|
|
|
- 支持 `Typescript`,健全的类型系统,智能的 `IDE` 提示。
|
|
|
|
|
- 支持 `Promise`。
|
|
|
|
|
- 支持 拦截器。
|
|
|
|
|
- 支持 取消请求。
|
|
|
|
|
- 支持 自定义合法状态码。
|
|
|
|
|
- 支持 自定义参数序列化。
|
|
|
|
|
- 支持 自定义转换数据。
|
|
|
|
|
- 支持 自定义错误处理。
|
|
|
|
|
- 支持 自定义平台适配器
|
2023-04-07 22:07:13 +08:00
|
|
|
|
- 支持 上传/下载
|
2023-04-12 17:36:05 +08:00
|
|
|
|
- 支持 派生领域
|
2023-04-07 22:07:13 +08:00
|
|
|
|
|
|
|
|
|
## 目前支持的平台
|
|
|
|
|
|
|
|
|
|
- [微信小程序](https://developers.weixin.qq.com/miniprogram/dev/framework/?from=axios-miniprogram)
|
|
|
|
|
- [支付宝小程序](https://opendocs.alipay.com/mini/developer/getting-started?from=axios-miniprogram)
|
|
|
|
|
- [百度小程序](https://smartprogram.baidu.com/developer/index.html?from=axios-miniprogram)
|
|
|
|
|
- [京东小程序](https://mp.jd.com?from=axios-miniprogram)
|
|
|
|
|
- [字节跳动小程序](https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/introduction/overview?from=axios-miniprogram)
|
|
|
|
|
- [QQ 小程序](https://q.qq.com/wiki/develop/miniprogram/frame/?from=axios-miniprogram)
|
|
|
|
|
- [钉钉小程序](https://open.dingtalk.com/document/org/develop-org-mini-programs?from=axios-miniprogram)
|
|
|
|
|
- [飞书小程序](https://open.feishu.cn/document/uYjL24iN/uMjNzUjLzYzM14yM2MTN?from=axios-miniprogram)
|
|
|
|
|
- [uni-app](https://uniapp.dcloud.net.cn?form=axios-miniprogram)
|
|
|
|
|
|
|
|
|
|
## 关于在跨端框架中使用时的支持度
|
|
|
|
|
|
|
|
|
|
问:在 uni-app 或者 Taro 等等这类跨端框架中使用时,该请求库支持 h5,APP,vue3,react 等等吗?
|
|
|
|
|
|
|
|
|
|
答:该请求库只是对框架提供的请求 API 进行了封装,并没有使用什么黑魔法。理论上来讲,框架支持的平台,该库也必然支持。
|
|
|
|
|
|
|
|
|
|
有问题欢迎反馈,请尽量把问题提到 [github issues](https://github.com/zjx0905/axios-miniprogram/issues) 中,这样更容易被我注意到。
|
2023-04-07 20:38:29 +08:00
|
|
|
|
|
2023-04-07 22:07:13 +08:00
|
|
|
|
[提问点这里](https://github.com/zjx0905/axios-miniprogram/issues)
|