filesystemmanager.removesavedfile(object object)
基础库 或更高版本; 若版本较低,建议采取 兼容处理。
主体: 企业支付宝小程序 、 个人支付宝小程序
相关文档: 本地缓存文件 、 filesystemmanager.getsavedfilelist
filesystemmanager.removesavedfile 删除指定的 本地缓存文件 。
object object
查看示例
属性 | 类型 | 默认值 | 必填 | 描述 |
---|---|---|---|---|
filepath | string | - | 是 | 需要删除的 本地缓存文件 路径。 |
success | function | - | 否 | 调用成功的回调函数。 |
fail | function | - | 否 | 调用失败的回调函数。 |
complete | function | - | 否 | 调用结束的回调函数(调用成功、失败都会执行)。 |
fail 回调的参数为 object,error
属性为错误码,errormessage
属性为错误消息。
错误码 | 错误消息 | 凯发app官方网站的解决方案 |
---|---|---|
2 | invalid parameter! | 请检查入参,参考类型和必填。 |
10022 | 文件不存在 {path} | 请检查文件,确保为本地存在的缓存文件。 |
10024 | 指定路径没有写权限 {path} | 请检查文件是否为本地缓存文件。 |
filesystemmanager.removesavedfile(object object)
从已保存的本地缓存文件列表中删除
let fs = my.getfilesystemmanager();
fs.removesavedfile({
filepath: 'https://resource/xxx',
success: res => {
console.log(res); // { success: true}
},
fail: err => {
console.log(err);
},
});
let fs = my.getfilesystemmanager();
my.getsavedfilelist({
success: res => {
console.log(res.filelist[0])
if (!res.filelist[0]) return;
fs.removesavedfile({
filepath: res.filelist[0].apfilepath,
success: res1 => {
console.log('删除成功', res1);
},
});
},
});