index.js
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// 防抖
function debounce(fn, time) {
let timer;
return function (...args) {
clearTimeout(timer);
timer = setTimeout(() => {
fn.apply(this, args);
clearTimeout(timer);
}, time);
};
}
// 节流
function throttle(fn, time) {
let inThrottle;
return function (...args) {
// const context = this;
// const args = arguments;
if (!inThrottle) {
fn.apply(this, args);
inThrottle = true;
setTimeout(function () {
inThrottle = false;
}, time);
}
};
}
// 获取周几
import * as moment from 'moment';
function getWeek(date) {
let week = moment.default(date).day();
switch (week) {
case 1:
return '周一';
case 2:
return '周二';
case 3:
return '周三';
case 4:
return '周四';
case 5:
return '周五';
case 6:
return '周六';
case 0:
return '周日';
}
}
function getTeamErrorLogo(team_logo) {
if (team_logo) {
return `this.src='${team_logo}';this.onerror=null`;
}
else {
return "this.src='https://img2.ydniu.com/app/images/team_logo.png';this.onerror=null";
}
}
export { debounce, throttle, getWeek, getTeamErrorLogo };
//# sourceMappingURL=index.js.map