//获取根目录找到图片
getImageUrl(){
console.log(this)
let that = this
console.log(that)
// 应用私有文档目录常量
plus.io.requestFileSystem( plus.io.PRIVATE_DOC , function(fs){
// fs.root是根目录操作对象DirectoryEntry
// 创建读取目录信息对象
var directoryReader = fs.root.createReader();
console.log(directoryReader)
directoryReader.readEntries( function( entries ){
console.log( entries.length)
var reg = /.(png|jpg|gif|jpeg|webp)$/;
entries.forEach( item =>{
console.log(item.name)
if(reg.test(item.name)) {
console.log(item.name)
console.log(that.imageList)
let name = '/storage/emulated/0/Android/data/io.dcloud.HBuilder/apps/HBuilder/doc/'+item.name
that.imageList.push(name)
console.log(that.imageList)
}
})
console.log(that.imageList)
}, function ( e ) {
alert( "Read entries failed: " + e.message );
} );
} );
}
|