更新记录

1.0.3(2026-06-12)

修复已知问题

1.0.2(2026-06-12)

去掉报错文件

1.0.1(2026-06-11)

文件选择器是基于 UTS 的 uni-app App 端文件选择器插件,支持 Android 和 iOS。

查看更多

平台兼容性

uni-app(5.12)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
× × 5.0 12 ×
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 小红书小程序 快应用-华为 快应用-联盟
× × × × × × × × × × × ×

uni-app x(5.12)

Chrome Safari Android iOS 鸿蒙 微信小程序
× × 5.0 12 × ×

wax-file-selector

wax-file-selector 是基于 UTS 的文件选择器 API 插件,支持 App Android 和 App iOS。

引入

import { chooseFile } from '@/uni_modules/wax-file-selector'

选择文件

chooseFile(
  {
    type: 'all'
  },
  (res) => {
    console.log(res)
  }
)

当前版本固定单选,不支持多选,count 参数不会生效。

参数

参数 类型 必填 说明
type String 可选:allimagevideo
extension Array\<String> 限制后缀,例如 ['pdf']['doc', 'docx']

Android 系统文件选择器按 MIME 类型做列表过滤,插件已内置常见文档后缀的 MIME 映射。无法映射 MIME 的自定义后缀会在用户选中文件后再按文件名后缀校验,不符合时返回 chooseFile:fail file extension not allowed

iOS 端使用系统文件选择器。插件会按传入的 extension 做选择结果校验,不符合时返回 chooseFile:fail file extension not allowed

返回

成功:

{
  "code": 0,
  "message": "success",
  "errMsg": "chooseFile:ok",
  "file": {
    "name": "example.pdf",
    "path": "/path/to/temp/example.pdf",
    "url": "content://...",
    "size": 1024,
    "extension": "pdf",
    "type": "application/pdf",
    "typeDescription": ""
  },
  "files": [
    {
      "name": "example.pdf",
      "path": "/path/to/temp/example.pdf",
      "url": "content://...",
      "size": 1024,
      "extension": "pdf",
      "type": "application/pdf",
      "typeDescription": ""
    }
  ],
  "tempFilePaths": [
    "/path/to/temp/example.pdf"
  ],
  "tempFiles": [
    {
      "name": "example.pdf",
      "path": "/path/to/temp/example.pdf",
      "url": "content://...",
      "size": 1024,
      "extension": "pdf",
      "type": "application/pdf",
      "typeDescription": ""
    }
  ]
}

取消:

{
  "code": 1,
  "message": "cancel",
  "errMsg": "chooseFile:fail cancel"
}

失败:

{
  "code": -1,
  "message": "error message",
  "errMsg": "chooseFile:fail error message"
}

示例

chooseFile({ type: 'image' }, handleChooseFile)
chooseFile({ type: 'video' }, handleChooseFile)
chooseFile({ type: 'all', extension: ['pdf'] }, handleChooseFile)
chooseFile({ type: 'all', extension: ['doc', 'docx'] }, handleChooseFile)

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

读取用户主动选择的本地文件

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。