Files
phone-app------test1-/uni_modules/lime-choose-file/readme copy.md
2026-06-02 10:42:33 +08:00

61 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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)文档来