2***@qq.com
2***@qq.com
  • 发布:2019-03-22 10:33
  • 更新:2019-03-22 14:26
  • 阅读:820

【报Bug】plus readEntries bug 少了几个方法

分类:HTML5+

先上代码:

plus.io.resolveLocalFileSystemURL('_doc/tempImage/compressed/', function(entry) {  
    //读取这个目录对象  
    var directoryReader = entry.createReader();  
    // console.log(dirPath)  
    //读取这个目录下的所有文件  
    directoryReader.readEntries(function(entries) {  
        //文件个数  
        var l = entries.length;  
        console.log(l)  
        //如果有才操作  
        if (l > 0) {  
            //记数最后一个给提示  
            var i;  
            //遍历删除文件  
            for (i = 0; i < l; i++) {  
                console.log(entries[i].fullPath)  
                for(var j in entries[i]){  
                    console.log(j)  
                }  
//                      entries[i].removeRecursively(function(entry) {  
//                          // console.log('.')  
//                          //删除成功回调  
//                      }, function(e) {  
//                          console.log('!!')  
//                          //错误信息  
//                          $.toast(e.message + ' ?!');  
//                      })  
            }  
        } else {  
            $.toast('这个目录下没有文件!')  
        }  
    }, function(e) {  
        $.toast('读取文件失败:' + e.message);  
    })  
}, function(e) {  
    $.toast('读取目录失败:' + e.message);  
})  

以前能用着,我是想删除指定目录下的所有文件及子目录
结果报 entries[i].removeRecursively is not a function....,打印entries对象的属性,结果对比手册发现少了:
remove: 删除目录
createReader: 创建目录读取对象
getDirectory: 创建或打开子目录
getFile: 创建或打开文件
removeRecursively: 递归删除目录
这几个方法....
我的环境是:
win10,hbx,小米6x

2019-03-22 10:33 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com (作者) - 嗯嗯嗯,撂了吧,我写bug呢。

没招了,我也是罪了,代码改了一下:

plus.io.resolveLocalFileSystemURL(dirPath, function(entry) {  
    //读取这个目录对象  
    var directoryReader = entry.createReader();  
    // console.log(dirPath)  
    //读取这个目录下的所有文件  
    directoryReader.readEntries(function(entries) {  
        // console.log(entries.length)  
        //如果有才操作  
        if (entries.length > 0) {  
            entry.removeRecursively(function(entry) {  
                // console.log('删除成功回调')  
                //删除成功回调  
            }, function(e) {  
                // console.log('!!')  
                //错误信息  
                $.toast(e.message + ' ?!');  
            })  
        }  
    }, function(e) {  
        $.toast('读取文件失败:' + e.message)  
    })  
}, function(e) {  
    $.toast('读取目录失败:' + e.message)  
})  

还好 resolveLocalFileSystemURL 的 success 返回值里有 removeRecursively 方法,试验成功了。
我明明记得以前都有着,重新升级了???也没有回答我....

该问题目前已经被锁定, 无法添加新回复