方法:
unique(arr) {
var hash = [];
for (var i = 0; i < arr.length; i++) {
if (hash.indexOf(arr[i]) == -1) {
hash.push(arr[i]);
}
}
return hash;
}
使用例子:
let masterImgList=[1,3,2,5,6,12,31,45,2,3,4,5,1,8];
let ImgList = this.unique(masterImgList);
console.log(ImgList); // 输出结果: [6,12,31,45,8]