npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@uni-helper/axios-adapter

v1.18.1

Published

The Axios adapter for uniapp

Readme

@uni-helper/axios-adapter

适用于 Vue2 和 Vue3 的 uniapp Axios 适配器

Ask DeepWiki

目录

简介

@uni-helper/axios-adapter 封装了 uni-app 的 uni.requestuni.downloadFileuni.uploadFile 等接口,让开发者可以在 uni-app 的各类平台上继续使用熟悉的 axios 编程范式。适配器同时为 TypeScript 项目提供全局类型扩展,补充 uploaddownload 以及 uni-app 专有请求参数的类型定义。

平台兼容性

| Vue 版本 | 支持情况 | | -------- | -------- | | Vue 2 | √ | | Vue 3 | √ |

| App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ 小程序 | | ---------------------------------------- | ------ | ---------- | ------------ | ---------- | ---------- | --------- | | HBuilderX 3.4.8app-vueapp-nvue | √ | √ | √ | √ | √ | √ |

| 钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 | | ---------- | ---------- | ---------- | ---------- | | √ | √ | √ | √ |

| H5-Safari | Android Browser | 微信浏览器(Android) | QQ 浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari | | --------- | --------------- | ------------------- | ------------------ | ------ | --- | ---- | ------- | --------- | | √ | √ | √ | √ | √ | √ | √ | √ | √ |

安装

pnpm i @uni-helper/axios-adapter axios

适配器与 axios 的版本需要保持主版本号和次版本号一致。当前适配器版本为 1.18.0,推荐搭配 axios@^1.18.0 使用。

快速开始

import { createUniAppAxiosAdapter } from '@uni-helper/axios-adapter'
import axios from 'axios'

axios.defaults.adapter = createUniAppAxiosAdapter()

配置完成后,即可像往常一样使用 axios.getaxios.post 等方法发起请求。

使用

创建自定义实例

import { createUniAppAxiosAdapter } from '@uni-helper/axios-adapter'
import axios from 'axios'

const instance = axios.create({ adapter: createUniAppAxiosAdapter() })

useAxios 一起使用

import { createUniAppAxiosAdapter } from '@uni-helper/axios-adapter'
import axios from 'axios'

axios.defaults.adapter = createUniAppAxiosAdapter()
const { data, isFinished } = useAxios('/posts')

上传和下载

// 下载
axios.download('/')
// or
axios.request({
  url: '/',
  method: 'download',
})

// 上传
axios.upload('/', new File([new Blob()], 'fake file'))
// or
axios.request({
  url: '/',
  method: 'upload',
  data: new File([new Blob()], 'fake file'),
})

小程序

自 axios 1.4.0 开始,axios 已对小程序环境做了兼容处理。若仍需在小程序中使用 FormDataBlob,可安装对应的 polyfill 并启用构建插件:

pnpm add miniprogram-formdata miniprogram-blob
// vite.config.js
import uniAxiosAdapter from '@uni-helper/axios-adapter/vite'

export default {
  plugins: [
    uniAxiosAdapter()
  ]
}

如果你使用的是 Vue CLI,改用 @uni-helper/axios-adapter/webpack 即可。

API 参考

createUniAppAxiosAdapter(options?: UserOptions): AxiosAdapter

创建适配器实例,可直接赋值给 axios.defaults.adapteraxios.create({ adapter })

  • options:可选配置对象,当前版本支持扩展 uni-app 请求参数(参见 globalExtensions.ts 中的类型定义)。
  • 返回值:标准的 AxiosAdapter 函数。

axios.upload<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>

uni.uploadFile 发送上传请求,data 通常为 FormData 实例。

axios.download<T>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>

uni.downloadFile 发起下载请求,返回的 response.data 默认为文件临时路径或 Buffer(取决于运行环境)。

版本策略

自 1.4.0 开始,请始终保持主版本号和次版本号与 axios 一致。例如当你安装了 1.5.1 版本时,你可以安装 axios 的 1.5.x 版本。这样做的目的是确保适配器始终支持最新的 axios 特性。

参与贡献

欢迎通过 Issue 或 Pull Request 参与改进本项目。开始前请阅读 CONTRIBUTING.md,了解本地开发、测试、提交规范与架构说明。

许可证

MIT