来个简单的节流函数
//节流throttle代码:
throttle(fn, time) {
let _arguments = arguments;
let canRun = true;
return function () {
if (!canRun) return;
canRun = false;
setTimeout(() => {
fn.call(this, _arguments);
canRun = true;
}, time);
};
},
throttle(create(),300); //这是调用