title: FileSystemManager.removeSavedFile header: develop nav: api

sidebar: FileSystemManager-removeSavedFile

解释:删除该小程序下已保存的本地用户文件。

方法参数:Object object

object参数说明

参数名 类型 必填 默认值 说明
filePath String - 需要删除的文件路径
success Function - 接口调用成功的回调函数
fail Function - 接口调用失败的回调函数
complete Function - 接口调用结束的回调函数(调用成功、失败都会执行)

代码示例

  • 在 js 文件中
  1. Page({
  2. onLoad() {
  3. const fs = swan.getFileSystemManager();
  4. this.fs = fs;
  5. },
  6. removeSavedFile() {
  7. this.fs.removeSavedFile({
  8. filePath: `${swan.env.USER_DATA_PATH}/demo.txt`,
  9. encoding: 'utf8',
  10. success: res => {
  11. console.log('removeSavedFile success', res);
  12. },
  13. fail: err => {
  14. console.log('removeSavedFile fail', err)
  15. }
  16. });
  17. }
  18. });