更新记录
1.0.0(2025-01-10)
happynur-choosefile
安卓可以做自定义界面,也可做系统自带文件管理器
ios暂时只支持系统自带的文件管理器
返回的是json格式。返回的数据你们想怎么用就怎么用吧,请随便
[
{
"filePath": "/storage/emulated/0/Pictures/aaaa.pdf",
"url": "file:///storage/emulated/0/Pictures/aaaa.pdf",
"size": 76949,
"file_type": "pdf",
"name": "aaaa.pdf"
},
{
"filePath": "/storage/emulated/0/Pictures/aaaa.pdf",
"url": "file:///storage/emulated/0/Pictures/aaaa.pdf",
"size": 76949,
"file_type": "pdf",
"name": "aaaa.pdf"
},
{
"filePath": "/storage/emulated/0/Pictures/aaaa.pdf",
"url": "file:///storage/emulated/0/Pictures/aaaa.pdf",
"size": 76949,
"file_type": "pdf",
"name": "aaaa.pdf"
},
{
"filePath": "/storage/emulated/0/Pictures/aaaa.pdf",
"url": "file:///storage/emulated/0/Pictures/aaaa.pdf",
"size": 76949,
"file_type": "pdf",
"name": "aaaa.pdf"
}
]
<template>
<view style="displa:flex;flex: 1;align-items: center;justify-content: center;">
<view style="height: 100px;"></view>
<happynur-choosefile widthRpx="673.6641" heightRpx="106.8702" @change="choose_end"
:chooseType="chooseType">
<view class="button_box pr">
<view class="my_button2">
<text class="text a105">上传本地文档</text>
<image class="icon24" :src="`/static/icon/file_trans_light.png`" mode=""></image>
</view>
</view>
</happynur-choosefile>
</view>
</template>
<script>
export default {
data() {
return {
// system 启动安卓手机的自带文件管理器, custom:返回pdf,doc,dox文件列表,然后自己写界面显示
chooseType:'system', //只支持安卓,
widthRpx:'',//随便写, 按钮显示位置
heightRpx:'',//随便写
multiple:false//只支持安卓chooseType为system的时候, 是否多选
}
},
watch:{
"file_info.fullPath":{
deep:true,
handler(fullPath){
}
}
},
methods: {
choose_end(files){
console.log(files);
// if(this.isIos){
// this.select_file(files[0])
// }else{
// if(this.chooseType=='system'){
// }else{
// }
// }
}
}
}
</script>
<style lang="scss">
.button_box{
/* #ifndef APP-NVUE */
margin: auto;
/* #endif */
.my_button2{
height: 106.8702rpx;
width: 673.6641rpx;
border-radius: 30.5344rpx;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background-color: #00CDE3;
.text{
margin-right: 15.2672rpx;
color: #ffffff;
font-size: 38.1679rpx;
}
.text.dark{
color: #0F0F10;
}
}
.my_button2.dark{
background-color: #008492;
}
}
</style>
平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | √ | √ | - | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
- | - | - | - | - | - | - | - | - | - | - |
happynur-choosefile
==```
试用时报错:Failed to mount component: template or render function not defined. found in......==
==如果试用时组件运行报错 [plugin:uni:helpers] 付费插件:uni_modules/happynur-choosefile 解析失败,请重新发行 请注意,原因是试用组件 被加密了 ,导致无法被解析到,正常购买不会有问题,如有其他问题可在群里提出,作者看到后会帮助解决处理。==
### 安卓可以做自定义界面,也可做系统自带文件管理器
### ios暂时只支持系统自带的文件管理器
###返回的是json格式。返回的数据你们想怎么用就怎么用吧,请随便
~~~
[
{
"filePath": "/storage/emulated/0/Pictures/aaaa.pdf",
"url": "file:///storage/emulated/0/Pictures/aaaa.pdf",
"size": 76949,
"file_type": "pdf",
"name": "aaaa.pdf"
},
{
"filePath": "/storage/emulated/0/Pictures/aaaa.pdf",
"url": "file:///storage/emulated/0/Pictures/aaaa.pdf",
"size": 76949,
"file_type": "pdf",
"name": "aaaa.pdf"
},
{
"filePath": "/storage/emulated/0/Pictures/aaaa.pdf",
"url": "file:///storage/emulated/0/Pictures/aaaa.pdf",
"size": 76949,
"file_type": "pdf",
"name": "aaaa.pdf"
},
{
"filePath": "/storage/emulated/0/Pictures/aaaa.pdf",
"url": "file:///storage/emulated/0/Pictures/aaaa.pdf",
"size": 76949,
"file_type": "pdf",
"name": "aaaa.pdf"
}
]
~~~
```vue
<template>
<view style="displa:flex;flex: 1;align-items: center;justify-content: center;">
<view style="height: 100px;"></view>
<happynur-choosefile widthRpx="673.6641" heightRpx="106.8702" @change="choose_end"
:chooseType="chooseType">
<view class="button_box pr">
<view class="my_button2">
<text class="text a105">上传本地文档</text>
<image class="icon24" :src="`/static/icon/file_trans_light.png`" mode=""></image>
</view>
</view>
</happynur-choosefile>
</view>
</template>
<script>
export default {
data() {
return {
// system 启动安卓手机的自带文件管理器, custom:返回pdf,doc,dox文件列表,然后自己写界面显示
chooseType:'system', //只支持安卓,
widthRpx:'',//随便写, 按钮显示位置
heightRpx:'',//随便写
multiple:false//只支持安卓chooseType为system的时候, 是否多选
}
},
watch:{
"file_info.fullPath":{
deep:true,
handler(fullPath){
}
}
},
methods: {
choose_end(files){
console.log(files);
// if(this.isIos){
// this.select_file(files[0])
// }else{
// if(this.chooseType=='system'){
// }else{
// }
// }
}
}
}
</script>
<style lang="scss">
.button_box{
/* #ifndef APP-NVUE */
margin: auto;
/* #endif */
.my_button2{
height: 106.8702rpx;
width: 673.6641rpx;
border-radius: 30.5344rpx;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background-color: #00CDE3;
.text{
margin-right: 15.2672rpx;
color: #ffffff;
font-size: 38.1679rpx;
}
.text.dark{
color: #0F0F10;
}
}
.my_button2.dark{
background-color: #008492;
}
}
</style>