//什么是Ajax? async JavaScript and XML(JSON) let xhr = new XMLHttpRequest(); xhr.open('GET','/requestHttpDemo'); // xhr.onload = () => { // console.log(…
// 概念:回城被打断 let debounce = (fn, time, asThis) => { let timer = null; return (...args) => { if (timer) { clearTimeout(timer) } timer = setTimeout(() => { fn.call(asThi…
// 概念:触发CD let debounce = (fn, time, asThis) => { let cooldown = false; let timer = null; return (...args) => { if (cooldown) { return; } fn.call(asThis, ...args) cooldo…
const eventHub = { map: {}, on: (key, fn) => { eventHub.map[key] = eventHub.map[key] || []; eventHub.map[key].push(fn); }, off: (key, fn) => { let mark = eventHub.map[ke…