赞
踩
- readFile() {
- const folderPath = 'file://storage/sdcard0/Android/data/io.dcloud.HBuilder/files/';
- this.aFileList = [];
- plus.io.resolveLocalFileSystemURL(
- folderPath, //指定的目录
- (entry) => {
- var directoryReader = entry.createReader(); //获取读取目录对象
- directoryReader.readEntries(
- (entries) => { //返回的是指定文件夹下的文件列表
- this.aFileList = entries
- this.aFileList.forEach(i => {
- if (/\./.test(i.name)) {
- this.list.push({
- name: i.name
- })
- }
- })
- },
- (err) => {
- console.log("访问目录失败");
- });
- },
- (err) => {
- console.log("访问指定目录失败:" + err.message);
- });
- },
注意:如果不用箭头函数的话,在plus.的方法里面是不能使用this访问外部变量的,一定一定要使用箭头函数处理。
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。