uniqueArr(arr, attr) {
const res = new Map();
return arr.filter((arr) => !res.has(arr[attr]) && res.set(arr[attr], 1));
},
created() {
let that = this;
that.getList();
that.timer = window.setInterval(() => {
that.getList();
}, 3 * 1000);
},
beforeDestroy() {
window.clearInterval(this.timer);
this.timer = null;
},
formatNumber(num) {
if (num >= 1e3 && num < 1e4) {
return (num / 1e3).toFixed(2) + "k";
} else if (num >= 1e4) {
return (num / 1e4).toFixed(2) + "w";
} else {
return num;
}
},
sortKey(arr, key) {
return arr.sort((a, b) => {
return b[key] - a[key]
})
},