-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathrunlist.js
More file actions
46 lines (39 loc) · 806 Bytes
/
runlist.js
File metadata and controls
46 lines (39 loc) · 806 Bytes
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
// 代码片段
let loading = false;
let aFn = [];
let timer = null;
const searchParams = {};
const id = 100;
const getDataList = () => {
loading = true;
const fn = () => {
// 数据请求
API.getList({
pageParam: {
...searchParams,
},
id: id,
})
.then((res) => {
loading = false;
// 数据渲染 this.dataLlist
this.dataList = res.list || [];
})
.catch((err) => {
loading = false;
alert(err.description);
});
};
aFn.push(fn);
if (timer) {
clearTimeout(timer);
}
aFn.length == 1 ? times = 0 : times = 300
timer = setTimeout(() => {
const fnNewest = aFn.pop();
if (fnNewest) {
fnNewest();
aFn = aFn.filter(Boolean);
}
}, times);
};