# FileSystemManager.rmdir(Object object)
异步删除目录。
# 支持情况
| 项 | 说明 |
|---|---|
| 兼容性 | 兼容微信 |
# 语法
const fs = mt.getFileSystemManager()
fs.rmdir({ dirPath, recursive, success, fail, complete })
# 参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| dirPath | string | — | 是 | 要删除的目录路径 |
| recursive | boolean | false | 否 | 是否递归删除目录下的文件和子目录 |
| success | function | — | 否 | 成功回调 |
| fail | function | — | 否 | 失败回调 |
| complete | function | — | 否 | 完成回调(成功或失败均触发) |
# 返回值
无返回值。
# 注意事项
recursive为false时,目录非空会触发 fail 回调。
# 示例代码
const fs = mt.getFileSystemManager()
fs.rmdir({
dirPath: `${mt.env.USER_DATA_PATH}/tempDir`,
recursive: true,
success() {
console.log('目录删除成功')
},
fail(err) {
console.error(err.errMsg)
}
})
# 与微信差异
无差异(行为与微信小游戏一致)。