swan.getSavedFileList
解释:获取本地已保存的文件列表
方法参数
Object object
object参数说明
success返回参数说明
fileList中的项目说明
示例
在开发者工具中预览效果
扫码体验
请使用百度APP扫码
图片示例
代码示例
Page({ data: { }, saveFile() { swan.downloadFile({ url: 'https://smartprogram.baidu.com/docs/img/file-simple.pdf', success: res => { swan.saveFile({ tempFilePath: res.tempFilePath, success: res => { this.toast('保存成功', 'none'); }, fail: err => { this.toast('保存失败,请稍后重试', 'none'); } }); }, fail: err => { this.toast('下载失败,请稍后重试', 'none'); } }); }, getSavedFileList() { swan.getSavedFileList({ success: res => { swan.showModal({ title: 'success', content: '目前保存文件数' + res.fileList.length }); console.log('getSavedFileList success', res); }, fail: err => { this.toast('fail', 'none'); console.log('getSavedFileList fail', err); } }); }, toast(title, icon) { swan.showToast({title, icon}); }});
