更新记录
1.0.0(2026-06-16) 下载此版本
首次发布,实现安卓、苹果和鸿蒙的文件选择功能
平台兼容性
uni-app(3.7.12)
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|
| √ | √ | - | - | - | - | √ | √ | √ |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 小红书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| - | - | - | - | - | - | - | - | - | - | - | - |
uni-app x(3.7.12)
| Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
|---|---|---|---|---|---|
| - | - | √ | √ | √ | - |
Afeng-uploadFile
功能
本地文件选择,例如.xls文件、.pdf文件等 uniapp运行到通过uts插件,实现了uniapp编译到安卓、苹果和鸿蒙App之后的文件选择功能。
使用方法
-
通过插件市场下载并导入项目,在uni_modules 目录下
import { chooseFileFromModule } from '../../uni_modules/Afeng-uploadFile' -
在需要的地方直接调用
chooseFileFromModule方法,示例中只用了complete完成回调,如何需要区分成功失败,可以自行实现success和fail回调。chooseFileFromModule({ complete: (res) => { console.log(res) let path = res.path let name = res.name let fileType = '' // 如果没有name,默认为:截取最后一个/之后的内容 if(!name) { let lastIndex = path.lastIndexOf('/'); if (lastIndex !== -1) { name = path.substring(lastIndex + 1); } else { name = Math.random().toString(36).substr(2) + Date.now(); } } // 使用 lastIndexOf 方法找到最后一个 . 的位置 let lastDotIndex = name.lastIndexOf('.'); if (lastDotIndex !== -1) { fileType = name.substring(lastDotIndex + 1); } else { console.log('文件路径中没有 .'); } let file = { size: res.size, path, fileType, name } console.log('根据需求构造的数据', file) } })
3、示例
```javascript
......
<button @tap="handleChooseFile">shangchuan</button>
......
import { chooseFileFromModule } from '../../uni_modules/Afeng-uploadFile'
const handleChooseFile= () =>{
chooseFileFromModule({
........
})
}
4、一定要打基座包!!!才可以实现该功能!!!

收藏人数:
下载插件并导入HBuilderX
赞赏(0)
下载 3
赞赏 0
下载 12263457
赞赏 1922
赞赏
京公网安备:11010802035340号