更新记录
1.0.1(2025-02-08) 下载此版本
修改APP端存放路径名称
1.0.0(2025-02-08) 下载此版本
文件选择器组件、多文件选择功能、文件类型识别功能(支持图片、文档、音频、视频、压缩包等)、文件列表展示功能、文件删除功能、H5平台支持、APP平台支持。
平台兼容性
Vue2 | Vue3 |
---|---|
√ | × |
App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|
app-vue | × | × | × | × | × | × |
钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 | 鸿蒙元服务 |
---|---|---|---|---|
× | × | × | × | × |
H5-Safari | Android Browser | 微信浏览器(Android) | QQ浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari |
---|---|---|---|---|---|---|---|---|
√ | √ | √ | √ | √ | × | √ | √ | √ |
文件选择器组件
一个简单易用的文件选择器组件,支持多文件选择、文件类型识别、文件列表展示等功能。
平台支持
- App ✅
- H5 ✅
安装方式
在插件市场右上角选择下载插件并导入HBuilderX
。
使用方法
- 引入组件
// 引入组件
import fileSelector from '@/uni_modules/zhouquan-fileSelector/components/zhouquan-fileSelector/file-selector.vue';
// 注册组件
components: {
fileSelector
},
- 在页面中使用组件
<template>
<fileSelector @fileSelected="onFileSelected" @filesChanged="onFilesChanged" />
</template>
- 处理文件选择事件
// 当选择文件完成时触发
onFileSelected(fileInfo) {
console.log('选择的文件:', fileInfo)
},
// 当文件发生变化时触发
onFilesChanged(fileList) {
console.log('文件列表:', fileList)
}
-
示例
<template>
<fileSelector @fileSelected="onFileSelected" @filesChanged="onFilesChanged"/>
</template>
<script>
import fileSelector from '@/uni_modules/zhouquan-fileSelector/components/zhouquan-fileSelector/file-selector.vue'
export default {
components: {
fileSelector
},
data() {
return {
title: ''
}
},
methods: {
// 当读取JSON文件完成时触发
onReadJSONFinish(result) {
if (result.jsonData) {
console.log('解析后的JSON数据:', result.jsonData)
} else {
console.log('原始字符串:', result.jsonStr)
}
},
// 当选择文件完成时触发
onFileSelected(fileInfo) {
console.log('选择的文件:', fileInfo)
},
// 当文件发生变化时触发
onFilesChanged(fileList) {
console.log('文件列表:', fileList)
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>