参数

    string path

    文件/目录路径

    boolean recursive

    返回值

    Stats|Object stats

    当 recursive 为 false 时,res.stats 是一个 Stats 对象。当 recursive 为 true 且 path 是一个目录的路径时,res.stats 是一个 Object,key 以 path 为根路径的相对路径,value 是该路径对应的 Stats 对象。

    错误

    示例代码

    recursive 为 true 时

    1. path: `$ {
    2. wx.env.USER_DATA_PATH
    3. }
    4. recursive: true,
    5. Object.keys(res.stats).forEach(path => {
    6. console.log(path, stats.isDirectory())
    7. })
    8. }