📌 从基础库 3.125.4 版本开始支持
名称 | 类型 | 说明 |
---|---|---|
path | string | 要判断是否存在的文件/目录路径(本地路径) |
const fs = xhs.getFileSystemManager(); // 同步判断文件/目录是否存在 try { fs.accessSync(`${xhs.env.USER_DATA_PATH}/hello.txt`); console.log("文件存在"); } catch(e) { console.error("错误信息:", e.errMsg); }