主题
lime-choosefile 文件选择
文件选择UTS API系参考小程序chooseFile API实现的,用法保持一致,目前仅支持uniappX(web,ios,安卓,鸿蒙)
文档
🚀 choose-file【站点1】 🌍 choose-file【站点2】 🔥 choose-file【站点3】
安装
导入,APP需要在页面上引入,然后自定义基座,完成自定义基座后,选择自定义基座运行
使用
UNIAPPX
js
import { chooseFile, type ChooseFileOption } from '@/uni_modules/LimeChooseFile'
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文档来