防抖
let time= null;
document.onmousemove = function (ev) {
if (time) {
clearTimeout(time)
}
time = setTimeout(() => {
// fn(ev)
}, 500)
)
};
节流
let previous= 0;
document.onmousemove = function (ev) {
let now = Date.now();
if (now - previous > 200) {
fn(ev);
previous = now;
}
};