以下是代码块,不知何原因总是报 indexOf undefined 好长时间了,求解,谢谢啦
downloadlist: function (options) {
var _this = this
var FileSystemManager = wx.getFileSystemManager();//声明文件管理器
var paths = wx.env.USER_DATA_PATH;
try {
var downloadlist = FileSystemManager.readdirSync(paths)
if (downloadlist.length >= 1) {
if (downloadlist.length == 1 && downloadlist[0] == “miniprogramLog”) {
_this.setData({
hidden: true,
load: false
})
} else {
var newFilenameArr = []
for (var i = 0; i < downloadlist.length; i++) {
var filename = downloadlist[i]
var extensionarr = filename.split(".");
var filenamearr = extensionarr[0].split("_");
switch (filenamearr[0]) {
case ‘level1’:
var level = “预备级上”;
break;
case ‘level2’:
var level = “预备级下”;
break;
case ‘level3’:
var level = “一级上”;
break;
case ‘level4’:
var level = “一级下”;
break;
case ‘level5’:
var level = “二级上”;
break;
case ‘level6’:
var level = “二级下”;
break;
case ‘level7’:
var level = “三级上”;
break;
case ‘level8’:
var level = “三级下”;
break;
}
var filename = filenamearr[0] + ‘_’ + filenamearr[1] + ‘_’ + filenamearr[2] + ‘.’ + extensionarr[1]
var idsting = filenamearr[0] + ‘_’ + filenamearr[1] + ‘_’ + filenamearr[2]
if (filenamearr[0] && filenamearr[1] && filenamearr[2] && filenamearr[0] !== ‘miniprogramLog’ && filenamearr[1] !== ‘miniprogramLog’ && filenamearr[2] !== ‘miniprogramLog’) {
var newarray = {
level: level,
unit: filenamearr[1],
part: filenamearr[2],
filePath: wx.env.USER_DATA_PATH + ‘/’ + filenamearr[0] + ‘_’ + filenamearr[1] + ‘_’ + filenamearr[2] + ‘.’ + extensionarr[1],
idsting: idsting,
isTouchMove: false //默认隐藏删除
}
newFilenameArr[i] = newarray
}
}
_this.setData({
downloadlistarr: newFilenameArr,
load: false
})
}
} else {
_this.setData({
hidden: true,
load: false
})
}
} catch (e) {
console.log(e)
}
},