-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
43 lines (34 loc) · 1.13 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>防抖和节流测试demo</title>
</head>
<body>
<button id="debounce">debounce</button>
<button id="throttle">throttle</button>
<script type="module">
import { debounce } from "./debounce.js";
import { throttle } from "./throttle.js";
const debounceBtn = document.querySelector('#debounce');
const throttleBtn = document.querySelector('#throttle');
const test = () => {
console.log('执行');
};
// const username = 'ocean'
// const user = {
// username: 'ocean123',
// sayHello: function () {
// console.log(`Hello ${this.username}`);
// }
// };
// const throttleSayHello = throttle(user.sayHello, 1000);
// throttleSayHello.apply(user)
const debounceFn = debounce(test, 1000, true);
const throttleFn = throttle(test, 1000);
debounceBtn.addEventListener('click', debounceFn);
throttleBtn.addEventListener('click', throttleFn);
</script>
</body>
</html>