主题
lime-choosefile 文件选择
- 文件选择UTS API系参考小程序chooseFile API实现的,用法保持一致,目前仅支持uniappX(web,ios,安卓)
文档
安装
使用
使用方法跟小程序的一样
js
// 非uniappx 不需要导入 ChooseFileOption
import { chooseFile, ChooseFileOption } from '@/uni_modules/LimeChooseFile'
const images = ref<string[]>([])
const onClick = () => {
chooseFile({
filename: 'xxxx', // 可选 用于给文件重命名
type: 'image',
success(res){
images.value = res.tempFiles.map((item):string => item.path)
console.log('res', res.tempFiles)
},
fail(err){
console.log('err', err)
}
//非uniappx 不需要 as ChooseFileOption
} as ChooseFileOption)
}
API
因为直接参照小程序chooseFile
API,所以可以直接按chooseFile文档来