(func, limit)
| 124 | |
| 125 | // 节流函数 |
| 126 | function throttle(func, limit) { |
| 127 | let inThrottle; |
| 128 | return function() { |
| 129 | if (!inThrottle) { |
| 130 | func.apply(this, arguments); |
| 131 | inThrottle = true; |
| 132 | setTimeout(() => inThrottle = false, limit); |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | // 初始化 |
| 138 | function init() { |