61 lines
1.7 KiB
Markdown
61 lines
1.7 KiB
Markdown
# lime-choosefile 文件选择
|
||
文件选择UTS API系参考小程序chooseFile API实现的,用法保持一致,目前仅支持uniappX(web,ios,安卓,鸿蒙)
|
||
|
||
|
||
## 文档
|
||
🚀 [choose-file【站点1】](https://limex.qcoon.cn/native/choose-file.html)
|
||
🌍 [choose-file【站点2】](https://limeui.netlify.app/native/choose-file.html)
|
||
🔥 [choose-file【站点3】](https://limeui.familyzone.top/native/choose-file.html)
|
||
|
||
|
||
|
||
## 安装
|
||
插件市场导入,APP需要在页面上引入,然后自定义基座,完成自定义基座后,选择自定义基座运行
|
||
|
||
## 使用
|
||
### UNIAPPX
|
||
```js
|
||
import { chooseFile, type ChooseFileOption } from '@/uni_modules/lime-choose-file'
|
||
|
||
const images = ref<string[]>([])
|
||
const onClick = () => {
|
||
chooseFile({
|
||
filename: 'xxxx', // 可选 用于给文件重命名(安卓、IOS)
|
||
type: 'image',
|
||
success(res){
|
||
images.value = res.tempFiles.map((item):string => item.path)
|
||
console.log('res', res.tempFiles)
|
||
},
|
||
fail(err){
|
||
console.log('err', err)
|
||
}
|
||
} as ChooseFileOption)
|
||
}
|
||
```
|
||
|
||
### UNIAPP
|
||
```js
|
||
import { chooseFile } from '@/uni_modules/lime-choose-file'
|
||
|
||
const images = ref<string[]>([])
|
||
const onClick = () => {
|
||
chooseFile({
|
||
filename: 'xxxx', // 可选 用于给文件重命名(安卓、IOS)
|
||
type: 'image',
|
||
success(res){
|
||
images.value = res.tempFiles.map((item):string => item.path)
|
||
console.log('res', res.tempFiles)
|
||
},
|
||
fail(err){
|
||
console.log('err', err)
|
||
}
|
||
})
|
||
}
|
||
```
|
||
|
||
## 常见问题
|
||
- 1、IOS路径是中文时无法上传到服务器,这时候需要设置`filename`给文件重命名
|
||
|
||
|
||
## API
|
||
因为直接参照小程序`chooseFile`API,所以可以直接按[chooseFile](https://uniapp.dcloud.net.cn/api/media/file.html#choosefile)文档来 |